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
|
|
|
|
* Enables modules and site configuration for a demo_umami site installation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Drupal\contact\Entity\ContactForm;
|
|
|
|
use Drupal\Core\Form\FormStateInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_form_FORM_ID_alter() for install_configure_form().
|
|
|
|
*
|
|
|
|
* Allows the profile to alter the site configuration form.
|
|
|
|
*/
|
|
|
|
function demo_umami_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
|
|
|
|
$form['site_information']['site_name']['#default_value'] = 'Umami Food Magazine';
|
|
|
|
$form['#submit'][] = 'demo_umami_form_install_configure_submit';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Submission handler to sync the contact.form.feedback recipient.
|
|
|
|
*/
|
|
|
|
function demo_umami_form_install_configure_submit($form, FormStateInterface $form_state) {
|
|
|
|
$site_mail = $form_state->getValue('site_mail');
|
|
|
|
ContactForm::load('feedback')->setRecipients([$site_mail])->trustData()->save();
|
2019-04-24 09:14:19 +00:00
|
|
|
|
|
|
|
$password = $form_state->getValue('account')['pass'];
|
|
|
|
demo_umami_set_users_passwords($password);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the password of admin to be the password for all users.
|
|
|
|
*/
|
|
|
|
function demo_umami_set_users_passwords($admin_password) {
|
|
|
|
// Collect the IDs of all users with roles editor or author.
|
|
|
|
$ids = \Drupal::entityQuery('user')
|
2021-04-12 09:40:17 +00:00
|
|
|
->accessCheck(FALSE)
|
2019-04-24 09:14:19 +00:00
|
|
|
->condition('roles', ['author', 'editor'], 'IN')
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$users = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple($ids);
|
|
|
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
$user->setPassword($admin_password);
|
|
|
|
$user->save();
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_toolbar().
|
|
|
|
*/
|
|
|
|
function demo_umami_toolbar() {
|
|
|
|
// Add a warning about using an experimental profile.
|
2018-06-21 21:43:41 +00:00
|
|
|
// @todo This can be removed once a generic warning for experimental profiles
|
|
|
|
// has been introduced. https://www.drupal.org/project/drupal/issues/2934374
|
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
|
|
|
$items['experimental-profile-warning'] = [
|
2018-02-01 23:07:12 +00:00
|
|
|
'#weight' => 999,
|
|
|
|
'#cache' => [
|
|
|
|
'contexts' => ['route'],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// Show warning only on administration pages.
|
|
|
|
$admin_context = \Drupal::service('router.admin_context');
|
|
|
|
if ($admin_context->isAdminRoute()) {
|
|
|
|
$items['experimental-profile-warning']['#type'] = 'toolbar_item';
|
|
|
|
$items['experimental-profile-warning']['tab'] = [
|
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
|
|
|
'#type' => 'inline_template',
|
2018-02-16 12:54:10 +00:00
|
|
|
'#template' => '<a class="toolbar-warning" href="{{ more_info_link }}">This site is intended for demonstration purposes.</a>',
|
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
|
|
|
'#context' => [
|
2018-02-03 22:52:49 +00:00
|
|
|
'more_info_link' => 'https://www.drupal.org/node/2941833',
|
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
|
|
|
],
|
|
|
|
'#attached' => [
|
|
|
|
'library' => ['demo_umami/toolbar-warning'],
|
|
|
|
],
|
2018-02-01 23:07:12 +00:00
|
|
|
];
|
|
|
|
}
|
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
|
|
|
return $items;
|
|
|
|
}
|