Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / lib / Drush / Drupal / DrupalKernel.php
1 <?php
2 namespace Drush\Drupal;
3
4 use Drush\Log\LogLevel;
5 use Drupal\Core\DrupalKernel as DrupalDrupalKernel;
6 use Symfony\Component\HttpFoundation\Request;
7 use Drupal\Core\DependencyInjection\ServiceModifierInterface;
8
9 class DrupalKernel extends DrupalDrupalKernel {
10   /** @var ServiceModifierInterface[] */
11   protected $serviceModifiers = [];
12
13   /**
14    * @inheritdoc
15    */
16   public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = TRUE, $app_root = NULL) {
17     drush_log(dt("Create from request"), LogLevel::DEBUG);
18     $kernel = new static($environment, $class_loader, $allow_dumping);
19     static::bootEnvironment();
20     $kernel->initializeSettings($request);
21     return $kernel;
22   }
23
24   /**
25    * Add a service modifier to the container builder.
26    *
27    * The container is not compiled until $kernel->boot(), so there is a chance
28    * for clients to add compiler passes et. al. before then.
29    */
30   public function addServiceModifier(ServiceModifierInterface $serviceModifier) {
31     drush_log(dt("add service modifier"), LogLevel::DEBUG);
32     $this->serviceModifiers[] = $serviceModifier;
33   }
34
35   /**
36    * @inheritdoc
37    */
38   protected function getContainerBuilder() {
39     drush_log(dt("get container builder"), LogLevel::DEBUG);
40     $container = parent::getContainerBuilder();
41     foreach ($this->serviceModifiers as $serviceModifier) {
42       $serviceModifier->alter($container);
43     }
44     return $container;
45   }
46   /**
47    * Initializes the service container.
48    *
49    * @return \Symfony\Component\DependencyInjection\ContainerInterface
50    */
51   protected function initializeContainer() {
52     if (empty($this->moduleList) && !$this->containerNeedsRebuild) {
53       $container_definition = $this->getCachedContainerDefinition();
54       foreach ($this->serviceModifiers as $serviceModifier) {
55         if (!$serviceModifier->check($container_definition)) {
56           $this->invalidateContainer();
57           break;
58         }
59       }
60     }
61     return parent::initializeContainer();
62   }
63 }