DrupalKernel.php

Namespace

Drush\Drupal

Classes

Namesort descending Description
DrupalKernel

File

lib/Drush/Drupal/DrupalKernel.php
View source
  1. <?php
  2. namespace Drush\Drupal;
  3. use Drush\Log\LogLevel;
  4. use Drupal\Core\DrupalKernel as DrupalDrupalKernel;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Drupal\Core\DependencyInjection\ServiceModifierInterface;
  7. class DrupalKernel extends DrupalDrupalKernel {
  8. /** @var ServiceModifierInterface[] */
  9. protected $serviceModifiers = [];
  10. /**
  11. * @inheritdoc
  12. */
  13. public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = TRUE, $app_root = NULL) {
  14. drush_log(dt("Create from request"), LogLevel::DEBUG);
  15. $kernel = new static($environment, $class_loader, $allow_dumping, $app_root);
  16. static::bootEnvironment($app_root);
  17. $kernel->initializeSettings($request);
  18. return $kernel;
  19. }
  20. /**
  21. * Add a service modifier to the container builder.
  22. *
  23. * The container is not compiled until $kernel->boot(), so there is a chance
  24. * for clients to add compiler passes et. al. before then.
  25. */
  26. public function addServiceModifier(ServiceModifierInterface $serviceModifier) {
  27. drush_log(dt("add service modifier"), LogLevel::DEBUG);
  28. $this->serviceModifiers[] = $serviceModifier;
  29. }
  30. /**
  31. * @inheritdoc
  32. */
  33. protected function getContainerBuilder() {
  34. drush_log(dt("get container builder"), LogLevel::DEBUG);
  35. $container = parent::getContainerBuilder();
  36. foreach ($this->serviceModifiers as $serviceModifier) {
  37. $serviceModifier->alter($container);
  38. }
  39. return $container;
  40. }
  41. }