Version 1
[yaffs-website] / vendor / drush / drush / lib / Drush / Drupal / DrupalKernel.php
diff --git a/vendor/drush/drush/lib/Drush/Drupal/DrupalKernel.php b/vendor/drush/drush/lib/Drush/Drupal/DrupalKernel.php
new file mode 100644 (file)
index 0000000..73456ed
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace Drush\Drupal;
+
+use Drush\Log\LogLevel;
+use Drupal\Core\DrupalKernel as DrupalDrupalKernel;
+use Symfony\Component\HttpFoundation\Request;
+use Drupal\Core\DependencyInjection\ServiceModifierInterface;
+
+class DrupalKernel extends DrupalDrupalKernel {
+  /** @var ServiceModifierInterface[] */
+  protected $serviceModifiers = [];
+
+  /**
+   * @inheritdoc
+   */
+  public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = TRUE, $app_root = NULL) {
+    drush_log(dt("Create from request"), LogLevel::DEBUG);
+    $kernel = new static($environment, $class_loader, $allow_dumping);
+    static::bootEnvironment();
+    $kernel->initializeSettings($request);
+    return $kernel;
+  }
+
+  /**
+   * Add a service modifier to the container builder.
+   *
+   * The container is not compiled until $kernel->boot(), so there is a chance
+   * for clients to add compiler passes et. al. before then.
+   */
+  public function addServiceModifier(ServiceModifierInterface $serviceModifier) {
+    drush_log(dt("add service modifier"), LogLevel::DEBUG);
+    $this->serviceModifiers[] = $serviceModifier;
+  }
+
+  /**
+   * @inheritdoc
+   */
+  protected function getContainerBuilder() {
+    drush_log(dt("get container builder"), LogLevel::DEBUG);
+    $container = parent::getContainerBuilder();
+    foreach ($this->serviceModifiers as $serviceModifier) {
+      $serviceModifier->alter($container);
+    }
+    return $container;
+  }
+}