Esempio n. 1
0
 /**
  * Display a given user's identity.
  *
  * @param \Drupal\Core\Session\AccountInterface|NULL $user
  *   The user to retrieve data on behalf of.
  *
  * @return array
  *   Render array with all the results.
  */
 public function display(AccountInterface $user = NULL)
 {
     // Build the output (as a render array).
     $output = ['#cache' => ['max-age' => 0]];
     if ($user) {
         $output['name'] = ['#markup' => $this->t('Name: %name', ['%name' => $user->getDisplayName()])];
         $output['mail'] = ['#markup' => $this->t('Mail: %mail', ['%mail' => $user->getEmail()])];
     }
     return $output;
 }
Esempio n. 2
0
 /**
  * Returns the parameters that will be used when Simpletest installs Drupal.
  *
  * @see install_drupal()
  * @see install_state_defaults()
  *
  * @return array
  *   Array of parameters for use in install_drupal().
  */
 protected function installParameters()
 {
     $connection_info = Database::getConnectionInfo();
     $driver = $connection_info['default']['driver'];
     $connection_info['default']['prefix'] = $connection_info['default']['prefix']['default'];
     unset($connection_info['default']['driver']);
     unset($connection_info['default']['namespace']);
     unset($connection_info['default']['pdo']);
     unset($connection_info['default']['init_commands']);
     // Remove database connection info that is not used by SQLite.
     if ($driver == 'sqlite') {
         unset($connection_info['default']['username']);
         unset($connection_info['default']['password']);
         unset($connection_info['default']['host']);
         unset($connection_info['default']['port']);
     }
     $parameters = array('interactive' => FALSE, 'parameters' => array('profile' => $this->profile, 'langcode' => 'en'), 'forms' => array('install_settings_form' => array('driver' => $driver, $driver => $connection_info['default']), 'install_configure_form' => array('site_name' => 'Drupal', 'site_mail' => '*****@*****.**', 'account' => array('name' => $this->rootUser->name, 'mail' => $this->rootUser->getEmail(), 'pass' => array('pass1' => $this->rootUser->pass_raw, 'pass2' => $this->rootUser->pass_raw)), 'update_status_module' => array(1 => NULL, 2 => NULL))));
     // If we only have one db driver available, we cannot set the driver.
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     if (count($this->getDatabaseTypes()) == 1) {
         unset($parameters['forms']['install_settings_form']['driver']);
     }
     return $parameters;
 }