Issue #2809635 by markconroy, navneet0693, alexpott, smaz, larowlan, Eli-T, webchick, yoroy, ikit-claw, budda, kjay, timmillwood, tkoleary, Gábor Hojtsy, andrewmacpherson, lauriii, JayKandari, jibran, ok_lyndsey, big_man, ckrina, nathancz, Paul_Gregory, vijaycs85, SharJay, tomphippen, tim.plunkett, Tarun Lewis, cehfisher, kreynen, Petr Illek, mariohernandez, thamas, thatdamnqa, John Cook, philipnorton42, h2cm, kattekrab, martin_q, waako: Create experimental installation profile
2018-01-19 00:51:57 +00:00
<?php
/**
* @file
* Install, update and uninstall functions for the demo_umami installation profile.
*/
use Drupal\user\Entity\User;
use Drupal\shortcut\Entity\Shortcut;
/**
* Implements hook_requirements().
*/
function demo_umami_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
2018-02-04 21:02:32 +00:00
$profile = \Drupal::installProfile();
$info = system_get_info('module', $profile);
Issue #2809635 by markconroy, navneet0693, alexpott, smaz, larowlan, Eli-T, webchick, yoroy, ikit-claw, budda, kjay, timmillwood, tkoleary, Gábor Hojtsy, andrewmacpherson, lauriii, JayKandari, jibran, ok_lyndsey, big_man, ckrina, nathancz, Paul_Gregory, vijaycs85, SharJay, tomphippen, tim.plunkett, Tarun Lewis, cehfisher, kreynen, Petr Illek, mariohernandez, thamas, thatdamnqa, John Cook, philipnorton42, h2cm, kattekrab, martin_q, waako: Create experimental installation profile
2018-01-19 00:51:57 +00:00
$requirements['experimental_profile_used'] = [
2018-02-04 21:02:32 +00:00
'title' => t('Experimental installation profile used'),
'value' => $info['name'],
'description' => t('Experimental profiles are provided for testing purposes only. Use at your own risk. To start building a new site, reinstall Drupal and choose a non-experimental profile.'),
Issue #2809635 by markconroy, navneet0693, alexpott, smaz, larowlan, Eli-T, webchick, yoroy, ikit-claw, budda, kjay, timmillwood, tkoleary, Gábor Hojtsy, andrewmacpherson, lauriii, JayKandari, jibran, ok_lyndsey, big_man, ckrina, nathancz, Paul_Gregory, vijaycs85, SharJay, tomphippen, tim.plunkett, Tarun Lewis, cehfisher, kreynen, Petr Illek, mariohernandez, thamas, thatdamnqa, John Cook, philipnorton42, h2cm, kattekrab, martin_q, waako: Create experimental installation profile
2018-01-19 00:51:57 +00:00
'severity' => REQUIREMENT_WARNING,
];
}
return $requirements;
}
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function demo_umami_install() {
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
// We install some menu links, so we have to rebuild the router, to ensure the
// menu links are valid.
\Drupal::service('router.builder')->rebuildIfNeeded();
// Populate the default shortcut set.
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => ['uri' => 'internal:/node/add'],
]);
$shortcut->save();
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
'link' => ['uri' => 'internal:/admin/content'],
]);
$shortcut->save();
// Enable the demo content module. This can't be specified as a dependency
// in the demo_umami.info.yml file, as it requires configuration provided by
// the profile (fields etc.).
\Drupal::service('module_installer')->install(['demo_umami_content'], TRUE);
}