Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,38 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Exception\AlreadyInstalledException.
*/
namespace Drupal\Core\Installer\Exception;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
* Exception thrown if Drupal is installed already.
*/
class AlreadyInstalledException extends InstallerException {
/**
* Constructs a new "already installed" exception.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation manager.
*/
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
$title = $this->t('Drupal already installed');
$message = $this->t('<ul>
<li>To start over, you must empty your existing database and copy <em>default.settings.php</em> over <em>settings.php</em>.</li>
<li>To upgrade an existing installation, proceed to the <a href="!update-url">update script</a>.</li>
<li>View your <a href="!base-url">existing site</a>.</li>
</ul>', array(
'!base-url' => $GLOBALS['base_url'],
'!update-url' => $GLOBALS['base_path'] . 'update.php',
));
parent::__construct($message, $title);
}
}

View file

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Exception\InstallerException.
*/
namespace Drupal\Core\Installer\Exception;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Base class for exceptions thrown by installer.
*/
class InstallerException extends \RuntimeException {
use StringTranslationTrait;
/**
* The page title to output.
*
* @var string
*/
protected $title;
/**
* Constructs a new installer exception.
*
* @param string $title
* The page title.
* @param string $message
* (optional) The exception message. Defaults to 'Error'.
* @param int $code
* (optional) The exception code. Defaults to 0.
* @param \Exception $previous
* (optional) A previous exception.
*/
public function __construct($message, $title = 'Error', $code = 0, \Exception $previous = NULL) {
parent::__construct($message, $code, $previous);
$this->title = $title;
}
/**
* Returns the exception page title.
*
* @return string
*/
public function getTitle() {
return $this->title;
}
}

View file

@ -0,0 +1,31 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Exception\NoProfilesException.
*/
namespace Drupal\Core\Installer\Exception;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
* Exception thrown if no installation profiles are available.
*/
class NoProfilesException extends InstallerException {
/**
* Constructs a new "no profiles available" exception.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation manager.
*/
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
$title = $this->t('No profiles available');
$message = $this->t('We were unable to find any installation profiles. Installation profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.');
parent::__construct($message, $title);
}
}

View file

@ -0,0 +1,101 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Form\SelectLanguageForm.
*/
namespace Drupal\Core\Installer\Form;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\UserAgent;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManager;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides the language selection form.
*/
class SelectLanguageForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'install_select_language_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) {
if (count($install_state['translations']) > 1) {
$files = $install_state['translations'];
}
else {
$files = array();
}
$standard_languages = LanguageManager::getStandardLanguageList();
$select_options = array();
$browser_options = array();
$form['#title'] = $this->t('Choose language');
// Build a select list with language names in native language for the user
// to choose from. And build a list of available languages for the browser
// to select the language default from.
// Select lists based on all standard languages.
foreach ($standard_languages as $langcode => $language_names) {
$select_options[$langcode] = $language_names[1];
$browser_options[$langcode] = $langcode;
}
// Add languages based on language files in the translations directory.
if (count($files)) {
foreach ($files as $langcode => $uri) {
$select_options[$langcode] = isset($standard_languages[$langcode]) ? $standard_languages[$langcode][1] : $langcode;
$browser_options[$langcode] = $langcode;
}
}
asort($select_options);
$request = Request::createFromGlobals();
$browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options);
$form['langcode'] = array(
'#type' => 'select',
'#title' => $this->t('Choose language'),
'#title_display' => 'invisible',
'#options' => $select_options,
// Use the browser detected language as default or English if nothing found.
'#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en',
);
$form['help'] = array(
'#type' => 'item',
'#markup' => SafeMarkup::format('<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>.
If you do not want this, select <a href="!english">English</a>.</p>', array(
'!english' => install_full_redirect_url(array('parameters' => array('langcode' => 'en'))),
)),
'#states' => array(
'invisible' => array(
'select[name="langcode"]' => array('value' => 'en'),
),
),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',
);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$build_info = $form_state->getBuildInfo();
$build_info['args'][0]['parameters']['langcode'] = $form_state->getValue('langcode');
$form_state->setBuildInfo($build_info);
}
}

View file

@ -0,0 +1,96 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Form\SelectProfileForm.
*/
namespace Drupal\Core\Installer\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides the profile selection form.
*/
class SelectProfileForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'install_select_profile_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) {
$form['#title'] = $this->t('Select an installation profile');
$profiles = array();
$names = array();
foreach ($install_state['profiles'] as $profile) {
/** @var $profile \Drupal\Core\Extension\Extension */
$details = install_profile_info($profile->getName());
// Don't show hidden profiles. This is used by to hide the testing profile,
// which only exists to speed up test runs.
if ($details['hidden'] === TRUE && !drupal_valid_test_ua()) {
continue;
}
$profiles[$profile->getName()] = $details;
// Determine the name of the profile; default to file name if defined name
// is unspecified.
$name = isset($details['name']) ? $details['name'] : $profile->getName();
$names[$profile->getName()] = $name;
}
// Display radio buttons alphabetically by human-readable name, but always
// put the core profiles first (if they are present in the filesystem).
natcasesort($names);
if (isset($names['minimal'])) {
// If the expert ("Minimal") core profile is present, put it in front of
// any non-core profiles rather than including it with them alphabetically,
// since the other profiles might be intended to group together in a
// particular way.
$names = array('minimal' => $names['minimal']) + $names;
}
if (isset($names['standard'])) {
// If the default ("Standard") core profile is present, put it at the very
// top of the list. This profile will have its radio button pre-selected,
// so we want it to always appear at the top.
$names = array('standard' => $names['standard']) + $names;
}
// The profile name and description are extracted for translation from the
// .info file, so we can use $this->t() on them even though they are dynamic
// data at this point.
$form['profile'] = array(
'#type' => 'radios',
'#title' => $this->t('Select an installation profile'),
'#title_display' => 'invisible',
'#options' => array_map(array($this, 't'), $names),
'#default_value' => 'standard',
);
foreach (array_keys($names) as $profile_name) {
$form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',
);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
global $install_state;
$install_state['parameters']['profile'] = $form_state->getValue('profile');
}
}

View file

@ -0,0 +1,305 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Form\SiteConfigureForm.
*/
namespace Drupal\Core\Installer\Form;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Locale\CountryManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\user\UserStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides the site configuration form.
*/
class SiteConfigureForm extends ConfigFormBase {
/**
* The site path.
*
* @var string
*/
protected $sitePath;
/**
* The user storage.
*
* @var \Drupal\user\UserStorageInterface
*/
protected $userStorage;
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* The module installer.
*
* @var \Drupal\Core\Extension\ModuleInstallerInterface
*/
protected $moduleInstaller;
/**
* The country manager.
*
* @var \Drupal\Core\Locale\CountryManagerInterface
*/
protected $countryManager;
/**
* The app root.
*
* @var string
*/
protected $root;
/**
* Constructs a new SiteConfigureForm.
*
* @param string $root
* The app root.
* @param string $site_path
* The site path.
* @param \Drupal\user\UserStorageInterface $user_storage
* The user storage.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
* @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer
* The module installer.
* @param \Drupal\Core\Locale\CountryManagerInterface $country_manager
* The country manager.
*/
public function __construct($root, $site_path, UserStorageInterface $user_storage, StateInterface $state, ModuleInstallerInterface $module_installer, CountryManagerInterface $country_manager) {
$this->root = $root;
$this->sitePath = $site_path;
$this->userStorage = $user_storage;
$this->state = $state;
$this->moduleInstaller = $module_installer;
$this->countryManager = $country_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('app.root'),
$container->get('site.path'),
$container->get('entity.manager')->getStorage('user'),
$container->get('state'),
$container->get('module_installer'),
$container->get('country_manager')
);
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'install_configure_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'system.date',
'system.site',
'update.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#title'] = $this->t('Configure site');
// Warn about settings.php permissions risk
$settings_dir = $this->sitePath;
$settings_file = $settings_dir . '/settings.php';
// Check that $_POST is empty so we only show this message when the form is
// first displayed, not on the next page after it is submitted. (We do not
// want to repeat it multiple times because it is a general warning that is
// not related to the rest of the installation process; it would also be
// especially out of place on the last page of the installer, where it would
// distract from the message that the Drupal installation has completed
// successfully.)
$post_params = $this->getRequest()->request->all();
if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'https://www.drupal.org/server-permissions')), 'warning');
}
$form['#attached']['library'][] = 'system/drupal.system';
// Add JavaScript time zone detection.
$form['#attached']['library'][] = 'core/drupal.timezone';
// We add these strings as settings because JavaScript translation does not
// work during installation.
$form['#attached']['drupalSettings']['copyFieldValue']['edit-site-mail'] = ['edit-account-mail'];
$form['site_information'] = array(
'#type' => 'fieldgroup',
'#title' => $this->t('Site information'),
);
$form['site_information']['site_name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Site name'),
'#required' => TRUE,
'#weight' => -20,
);
$form['site_information']['site_mail'] = array(
'#type' => 'email',
'#title' => $this->t('Site email address'),
'#default_value' => ini_get('sendmail_from'),
'#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."),
'#required' => TRUE,
'#weight' => -15,
);
$form['admin_account'] = array(
'#type' => 'fieldgroup',
'#title' => $this->t('Site maintenance account'),
);
$form['admin_account']['account']['name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Username'),
'#maxlength' => USERNAME_MAX_LENGTH,
'#description' => $this->t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'),
'#required' => TRUE,
'#attributes' => array('class' => array('username')),
);
$form['admin_account']['account']['pass'] = array(
'#type' => 'password_confirm',
'#required' => TRUE,
'#size' => 25,
);
$form['admin_account']['account']['#tree'] = TRUE;
$form['admin_account']['account']['mail'] = array(
'#type' => 'email',
'#title' => $this->t('Email address'),
'#required' => TRUE,
);
$form['regional_settings'] = array(
'#type' => 'fieldgroup',
'#title' => $this->t('Regional settings'),
);
$countries = $this->countryManager->getList();
$form['regional_settings']['site_default_country'] = array(
'#type' => 'select',
'#title' => $this->t('Default country'),
'#empty_value' => '',
'#default_value' => $this->config('system.date')->get('country.default'),
'#options' => $countries,
'#description' => $this->t('Select the default country for the site.'),
'#weight' => 0,
);
$form['regional_settings']['date_default_timezone'] = array(
'#type' => 'select',
'#title' => $this->t('Default time zone'),
// Use system timezone if set, but avoid throwing a warning in PHP >=5.4
'#default_value' => @date_default_timezone_get(),
'#options' => system_time_zones(),
'#description' => $this->t('By default, dates in this site will be displayed in the chosen time zone.'),
'#weight' => 5,
'#attributes' => array('class' => array('timezone-detect')),
);
$form['update_notifications'] = array(
'#type' => 'fieldgroup',
'#title' => $this->t('Update notifications'),
);
$form['update_notifications']['update_status_module'] = array(
'#type' => 'checkboxes',
'#title' => $this->t('Update notifications'),
'#options' => array(
1 => $this->t('Check for updates automatically'),
2 => $this->t('Receive email notifications'),
),
'#default_value' => array(1, 2),
'#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href="@drupal">Drupal.org</a>.', array('@drupal' => 'https://www.drupal.org')),
'#weight' => 15,
);
$form['update_notifications']['update_status_module'][2] = array(
'#states' => array(
'visible' => array(
'input[name="update_status_module[1]"]' => array('checked' => TRUE),
),
),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#weight' => 15,
'#button_type' => 'primary',
);
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($error = user_validate_name($form_state->getValue(array('account', 'name')))) {
$form_state->setErrorByName('account][name', $error);
}
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('system.site')
->set('name', (string) $form_state->getValue('site_name'))
->set('mail', (string) $form_state->getValue('site_mail'))
->save(TRUE);
$this->config('system.date')
->set('timezone.default', (string) $form_state->getValue('date_default_timezone'))
->set('country.default', (string) $form_state->getValue('site_default_country'))
->save(TRUE);
$account_values = $form_state->getValue('account');
// Enable update.module if this option was selected.
$update_status_module = $form_state->getValue('update_status_module');
if ($update_status_module[1]) {
$this->moduleInstaller->install(array('file', 'update'), FALSE);
// Add the site maintenance account's email address to the list of
// addresses to be notified when updates are available, if selected.
if ($update_status_module[2]) {
// Reset the configuration factory so it is updated with the new module.
$this->resetConfigFactory();
$this->config('update.settings')->set('notification.emails', array($account_values['mail']))->save(TRUE);
}
}
// We precreated user 1 with placeholder values. Let's save the real values.
$account = $this->userStorage->load(1);
$account->init = $account->mail = $account_values['mail'];
$account->roles = $account->getRoles();
$account->activate();
$account->timezone = $form_state->getValue('date_default_timezone');
$account->pass = $account_values['pass'];
$account->name = $account_values['name'];
$account->save();
// Record when this install ran.
$this->state->set('install_time', $_SERVER['REQUEST_TIME']);
}
}

View file

@ -0,0 +1,200 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\Form\SiteSettingsForm.
*/
namespace Drupal\Core\Installer\Form;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form to configure and rewrite settings.php.
*/
class SiteSettingsForm extends FormBase {
/**
* The site path.
*
* @var string
*/
protected $sitePath;
/**
* Constructs a new SiteSettingsForm.
*
* @param string $site_path
* The site path.
*/
public function __construct($site_path) {
$this->sitePath = $site_path;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('site.path')
);
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'install_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$settings_file = './' . $this->sitePath . '/settings.php';
$form['#title'] = $this->t('Database configuration');
$drivers = drupal_get_database_types();
$drivers_keys = array_keys($drivers);
// Unless there is input for this form (for a non-interactive installation,
// input originates from the $settings array passed into install_drupal()),
// check whether database connection settings have been prepared in
// settings.php already.
// Note: The installer even executes this form if there is a valid database
// connection already, since the submit handler of this form is responsible
// for writing all $settings to settings.php (not limited to $databases).
$input = &$form_state->getUserInput();
if (!isset($input['driver']) && $database = Database::getConnectionInfo()) {
$input['driver'] = $database['default']['driver'];
$input[$database['default']['driver']] = $database['default'];
}
if (isset($input['driver'])) {
$default_driver = $input['driver'];
// In case of database connection info from settings.php, as well as for a
// programmed form submission (non-interactive installer), the table prefix
// information is usually normalized into an array already, but the form
// element only allows to configure one default prefix for all tables.
$prefix = &$input[$default_driver]['prefix'];
if (isset($prefix) && is_array($prefix)) {
$prefix = $prefix['default'];
}
$default_options = $input[$default_driver];
}
// If there is no database information yet, suggest the first available driver
// as default value, so that its settings form is made visible via #states
// when JavaScript is enabled (see below).
else {
$default_driver = current($drivers_keys);
$default_options = array();
}
$form['driver'] = array(
'#type' => 'radios',
'#title' => $this->t('Database type'),
'#required' => TRUE,
'#default_value' => $default_driver,
);
if (count($drivers) == 1) {
$form['driver']['#disabled'] = TRUE;
}
// Add driver specific configuration options.
foreach ($drivers as $key => $driver) {
$form['driver']['#options'][$key] = $driver->name();
$form['settings'][$key] = $driver->getFormOptions($default_options);
$form['settings'][$key]['#prefix'] = '<h2 class="js-hide">' . $this->t('@driver_name settings', array('@driver_name' => $driver->name())) . '</h2>';
$form['settings'][$key]['#type'] = 'container';
$form['settings'][$key]['#tree'] = TRUE;
$form['settings'][$key]['advanced_options']['#parents'] = array($key);
$form['settings'][$key]['#states'] = array(
'visible' => array(
':input[name=driver]' => array('value' => $key),
)
);
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',
'#limit_validation_errors' => array(
array('driver'),
array($default_driver),
),
'#submit' => array('::submitForm'),
);
$form['errors'] = array();
$form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$driver = $form_state->getValue('driver');
$database = $form_state->getValue($driver);
$drivers = drupal_get_database_types();
$reflection = new \ReflectionClass($drivers[$driver]);
$install_namespace = $reflection->getNamespaceName();
// Cut the trailing \Install from namespace.
$database['namespace'] = substr($install_namespace, 0, strrpos($install_namespace, '\\'));
$database['driver'] = $driver;
$form_state->set('database', $database);
$errors = install_database_errors($database, $form_state->getValue('settings_file'));
foreach ($errors as $name => $message) {
$form_state->setErrorByName($name, $message);
}
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
global $install_state;
// Update global settings array and save.
$settings = array();
$database = $form_state->get('database');
$settings['databases']['default']['default'] = (object) array(
'value' => $database,
'required' => TRUE,
);
$settings['settings']['hash_salt'] = (object) array(
'value' => Crypt::randomBytesBase64(55),
'required' => TRUE,
);
// Remember the profile which was used.
$settings['settings']['install_profile'] = (object) array(
'value' => $install_state['parameters']['profile'],
'required' => TRUE,
);
drupal_rewrite_settings($settings);
// Add the config directories to settings.php.
drupal_install_config_directories();
// Indicate that the settings file has been verified, and check the database
// for the last completed task, now that we have a valid connection. This
// last step is important since we want to trigger an error if the new
// database already has Drupal installed.
$install_state['settings_verified'] = TRUE;
$install_state['config_verified'] = TRUE;
$install_state['database_verified'] = TRUE;
$install_state['completed_task'] = install_verify_completed_task();
}
}

View file

@ -0,0 +1,50 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\InstallerKernel.
*/
namespace Drupal\Core\Installer;
use Drupal\Core\DrupalKernel;
/**
* Extend DrupalKernel to handle force some kernel behaviors.
*/
class InstallerKernel extends DrupalKernel {
/**
* {@inheritdoc}
*
* @param bool $rebuild
* Force a container rebuild. Unlike the parent method, this defaults to
* TRUE.
*/
protected function initializeContainer($rebuild = TRUE) {
$container = parent::initializeContainer($rebuild);
return $container;
}
/**
* Reset the bootstrap config storage.
*
* Use this from a database driver runTasks() if the method overrides the
* bootstrap config storage. Normally the bootstrap config storage is not
* re-instantiated during a single install request. Most drivers will not
* need this method.
*
* @see \Drupal\Core\Database\Install\Tasks::runTasks().
*/
public function resetConfigStorage() {
$this->configStorage = NULL;
}
/**
* {@inheritdoc}
*/
protected function addServiceFiles($service_yamls) {
// In the beginning there is no settings.php and no service YAMLs.
return parent::addServiceFiles($service_yamls ?: []);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\InstallerRouteBuilder.
*/
namespace Drupal\Core\Installer;
use Drupal\Core\Routing\RouteBuilder;
/**
* Manages the router in the installer.
*/
class InstallerRouteBuilder extends RouteBuilder {
/**
* {@inheritdoc}
*
* Overridden to return no routes.
*
* @todo Convert installer steps into routes; add an installer.routing.yml.
*/
protected function getRouteDefinitions() {
return array();
}
}

View file

@ -0,0 +1,84 @@
<?php
/**
* @file
* Contains \Drupal\Core\Installer\InstallerServiceProvider.
*/
namespace Drupal\Core\Installer;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Symfony\Component\DependencyInjection\Reference;
/**
* Service provider for the early installer environment.
*
* This class is manually added by install_begin_request() via
* $conf['container_service_providers'] and required to prevent various services
* from trying to retrieve data from storages that do not exist yet.
*/
class InstallerServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
// Inject the special configuration storage for the installer.
// This special implementation MUST NOT be used anywhere else than the early
// installer environment.
$container->register('config.storage', 'Drupal\Core\Config\InstallStorage');
// Replace services with in-memory implementations.
$definition = $container->getDefinition('cache_factory');
$definition->setClass('Drupal\Core\Cache\MemoryBackendFactory');
$definition->setArguments(array());
$definition->setMethodCalls(array());
$container
->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory');
$container
->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory');
// Replace services with no-op implementations.
$container
->register('lock', 'Drupal\Core\Lock\NullLockBackend');
$container
->register('url_generator', 'Drupal\Core\Routing\NullGenerator')
->addArgument(new Reference('request_stack'));
$container
->register('router.dumper', 'Drupal\Core\Routing\NullMatcherDumper');
// Remove the cache tags invalidator tag from the cache tags storage, so
// that we don't call it when cache tags are invalidated very early in the
// installer.
$container->getDefinition('cache_tags.invalidator.checksum')
->clearTag('cache_tags_invalidator');
// Replace the route builder with an empty implementation.
// @todo Convert installer steps into routes; add an installer.routing.yml.
$definition = $container->getDefinition('router.builder');
$definition->setClass('Drupal\Core\Installer\InstallerRouteBuilder');
}
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
// Disable Twig cache (php storage does not exist yet).
$twig_config = $container->getParameter('twig.config');
$twig_config['cache'] = FALSE;
$container->setParameter('twig.config', $twig_config);
// No service may persist when the early installer kernel is rebooted into
// the production environment.
// @todo The DrupalKernel reboot performed by drupal_install_system() is
// actually not a "regular" reboot (like ModuleHandler::install()), so
// services are not actually persisted.
foreach ($container->findTaggedServiceIds('persist') as $id => $tags) {
$definition = $container->getDefinition($id);
$definition->clearTag('persist');
}
}
}