class InstallerServiceProvider
Same name in other branches
- 9 core/lib/Drupal/Core/Installer/InstallerServiceProvider.php \Drupal\Core\Installer\InstallerServiceProvider
- 8.9.x core/lib/Drupal/Core/Installer/InstallerServiceProvider.php \Drupal\Core\Installer\InstallerServiceProvider
- 10 core/lib/Drupal/Core/Installer/InstallerServiceProvider.php \Drupal\Core\Installer\InstallerServiceProvider
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.
Hierarchy
- class \Drupal\Core\Installer\NormalInstallerServiceProvider implements \Drupal\Core\DependencyInjection\ServiceProviderInterface
- class \Drupal\Core\Installer\InstallerServiceProvider extends \Drupal\Core\Installer\NormalInstallerServiceProvider implements \Drupal\Core\DependencyInjection\ServiceProviderInterface, \Drupal\Core\DependencyInjection\ServiceModifierInterface
Expanded class hierarchy of InstallerServiceProvider
File
-
core/
lib/ Drupal/ Core/ Installer/ InstallerServiceProvider.php, line 17
Namespace
Drupal\Core\InstallerView source
class InstallerServiceProvider extends NormalInstallerServiceProvider 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.
$container->register('keyvalue', 'Drupal\\Core\\KeyValueStore\\KeyValueMemoryFactory');
$container->register('keyvalue.expirable', 'Drupal\\Core\\KeyValueStore\\KeyValueNullExpirableFactory');
// Replace services with no-op implementations.
$container->register('url_generator', 'Drupal\\Core\\Routing\\NullGenerator')
->addArgument(new Reference('request_stack'));
$container->register('path_processor_manager', 'Drupal\\Core\\PathProcessor\\NullPathProcessorManager');
$container->register('router.dumper', 'Drupal\\Core\\Routing\\NullMatcherDumper');
// 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')
->setLazy(FALSE);
parent::register($container);
}
/**
* {@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 ModuleInstaller::install()), so
// services are not actually persisted.
foreach ($container->findTaggedServiceIds('persist') as $id => $tags) {
$definition = $container->getDefinition($id);
$definition->clearTag('persist');
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
InstallerServiceProvider::alter | public | function | Modifies existing service definitions. | Overrides ServiceModifierInterface::alter |
InstallerServiceProvider::register | public | function | Registers services to the container. | Overrides NormalInstallerServiceProvider::register |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.