Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Installer;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\DependencyInjection\ContainerBuilder;
|
Chris@0
|
6 use Drupal\Core\DependencyInjection\ServiceProviderInterface;
|
Chris@0
|
7 use Drupal\Core\DependencyInjection\ServiceModifierInterface;
|
Chris@0
|
8 use Symfony\Component\DependencyInjection\Reference;
|
Chris@0
|
9
|
Chris@0
|
10 /**
|
Chris@0
|
11 * Service provider for the early installer environment.
|
Chris@0
|
12 *
|
Chris@0
|
13 * This class is manually added by install_begin_request() via
|
Chris@0
|
14 * $conf['container_service_providers'] and required to prevent various services
|
Chris@0
|
15 * from trying to retrieve data from storages that do not exist yet.
|
Chris@0
|
16 */
|
Chris@0
|
17 class InstallerServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * {@inheritdoc}
|
Chris@0
|
21 */
|
Chris@0
|
22 public function register(ContainerBuilder $container) {
|
Chris@0
|
23 // Inject the special configuration storage for the installer.
|
Chris@0
|
24 // This special implementation MUST NOT be used anywhere else than the early
|
Chris@0
|
25 // installer environment.
|
Chris@0
|
26 $container->register('config.storage', 'Drupal\Core\Config\InstallStorage');
|
Chris@0
|
27
|
Chris@0
|
28 // Replace services with in-memory implementations.
|
Chris@0
|
29 $definition = $container->getDefinition('cache_factory');
|
Chris@0
|
30 $definition->setClass('Drupal\Core\Cache\MemoryBackendFactory');
|
Chris@0
|
31 $definition->setArguments([]);
|
Chris@0
|
32 $definition->setMethodCalls([]);
|
Chris@0
|
33 $container
|
Chris@0
|
34 ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory');
|
Chris@0
|
35 $container
|
Chris@0
|
36 ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory');
|
Chris@0
|
37
|
Chris@0
|
38 // Replace services with no-op implementations.
|
Chris@0
|
39 $container
|
Chris@0
|
40 ->register('lock', 'Drupal\Core\Lock\NullLockBackend');
|
Chris@0
|
41 $container
|
Chris@0
|
42 ->register('url_generator', 'Drupal\Core\Routing\NullGenerator')
|
Chris@0
|
43 ->addArgument(new Reference('request_stack'));
|
Chris@0
|
44 $container
|
Chris@0
|
45 ->register('path_processor_manager', 'Drupal\Core\PathProcessor\NullPathProcessorManager');
|
Chris@0
|
46 $container
|
Chris@0
|
47 ->register('router.dumper', 'Drupal\Core\Routing\NullMatcherDumper');
|
Chris@0
|
48
|
Chris@0
|
49 // Remove the cache tags invalidator tag from the cache tags storage, so
|
Chris@0
|
50 // that we don't call it when cache tags are invalidated very early in the
|
Chris@0
|
51 // installer.
|
Chris@0
|
52 $container->getDefinition('cache_tags.invalidator.checksum')
|
Chris@0
|
53 ->clearTag('cache_tags_invalidator');
|
Chris@0
|
54
|
Chris@0
|
55 // Replace the route builder with an empty implementation.
|
Chris@0
|
56 // @todo Convert installer steps into routes; add an installer.routing.yml.
|
Chris@0
|
57 $definition = $container->getDefinition('router.builder');
|
Chris@0
|
58 $definition->setClass('Drupal\Core\Installer\InstallerRouteBuilder')
|
Chris@0
|
59 // The core router builder, but there is no reason here to be lazy, so
|
Chris@0
|
60 // we don't need to ship with a custom proxy class.
|
Chris@0
|
61 ->setLazy(FALSE);
|
Chris@17
|
62
|
Chris@17
|
63 // Use a performance optimised module extension list.
|
Chris@17
|
64 $container->getDefinition('extension.list.module')->setClass('Drupal\Core\Installer\InstallerModuleExtensionList');
|
Chris@0
|
65 }
|
Chris@0
|
66
|
Chris@0
|
67 /**
|
Chris@0
|
68 * {@inheritdoc}
|
Chris@0
|
69 */
|
Chris@0
|
70 public function alter(ContainerBuilder $container) {
|
Chris@0
|
71 // Disable Twig cache (php storage does not exist yet).
|
Chris@0
|
72 $twig_config = $container->getParameter('twig.config');
|
Chris@0
|
73 $twig_config['cache'] = FALSE;
|
Chris@0
|
74 $container->setParameter('twig.config', $twig_config);
|
Chris@0
|
75
|
Chris@0
|
76 // No service may persist when the early installer kernel is rebooted into
|
Chris@0
|
77 // the production environment.
|
Chris@0
|
78 // @todo The DrupalKernel reboot performed by drupal_install_system() is
|
Chris@0
|
79 // actually not a "regular" reboot (like ModuleInstaller::install()), so
|
Chris@0
|
80 // services are not actually persisted.
|
Chris@0
|
81 foreach ($container->findTaggedServiceIds('persist') as $id => $tags) {
|
Chris@0
|
82 $definition = $container->getDefinition($id);
|
Chris@0
|
83 $definition->clearTag('persist');
|
Chris@0
|
84 }
|
Chris@0
|
85 }
|
Chris@0
|
86
|
Chris@0
|
87 }
|