getValue('site_mail'); ContactForm::load('feedback')->setRecipients([$site_mail])->trustData()->save(); $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') ->accessCheck(FALSE) ->condition('roles', ['author', 'editor'], 'IN') ->execute(); $users = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple($ids); foreach ($users as $user) { $user->setPassword($admin_password); $user->save(); } } /** * Implements hook_toolbar(). */ function demo_umami_toolbar() { // Add a warning about using an experimental profile. // @todo This can be removed once a generic warning for experimental profiles // has been introduced. https://www.drupal.org/project/drupal/issues/2934374 $items['experimental-profile-warning'] = [ '#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'] = [ '#type' => 'inline_template', '#template' => 'This site is intended for demonstration purposes.', '#context' => [ 'more_info_link' => 'https://www.drupal.org/node/2941833', ], '#attached' => [ 'library' => ['demo_umami/toolbar-warning'], ], ]; } return $items; }