DrupalKernelInterface.php 3.71 KB
Newer Older
1 2 3 4
<?php

namespace Drupal\Core;

5
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
6
use Symfony\Component\HttpKernel\HttpKernelInterface;
7
use Symfony\Component\HttpFoundation\Request;
8 9 10 11 12 13 14

/**
 * The interface for DrupalKernel, the core of Drupal.
 *
 * This interface extends Symfony's KernelInterface and adds methods for
 * responding to modules being enabled or disabled during its lifetime.
 */
15
interface DrupalKernelInterface extends HttpKernelInterface, ContainerAwareInterface {
16

17 18 19 20 21 22 23 24 25 26
  /**
   * Event fired when the service container finished initializing in subrequest.
   *
   * This event allows you to initialize overrides such as language to the
   * services.
   *
   * @var string
   */
  const CONTAINER_INITIALIZE_SUBREQUEST_FINISHED = 'kernel.container.finish_container_initialize_subrequest';

27 28
  /**
   * Boots the current kernel.
29 30
   *
   * @return $this
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
   */
  public function boot();

  /**
   * Shuts down the kernel.
   */
  public function shutdown();

  /**
   * Discovers available serviceProviders.
   *
   * @return array
   *   The available serviceProviders.
   */
  public function discoverServiceProviders();

  /**
   * Returns all registered service providers.
   *
50 51 52
   * @param string $origin
   *   The origin for which to return service providers; one of 'app' or 'site'.
   *
53 54 55
   * @return array
   *   An associative array of ServiceProvider objects, keyed by name.
   */
56
  public function getServiceProviders($origin);
57 58 59 60

  /**
   * Gets the current container.
   *
61 62
   * @return \Symfony\Component\DependencyInjection\ContainerInterface
   *   A ContainerInterface instance.
63 64
   */
  public function getContainer();
65

66 67 68 69 70
  /**
   * Returns the cached container definition - if any.
   *
   * This also allows inspecting a built container for debugging purposes.
   *
71
   * @return array|null
72 73 74 75
   *   The cached container definition or NULL if not found in cache.
   */
  public function getCachedContainerDefinition();

76 77 78
  /**
   * Set the current site path.
   *
79
   * @param string $path
80
   *   The current site path.
81 82 83
   *
   * @throws \LogicException
   *   In case the kernel is already booted.
84 85 86 87 88 89 90 91 92 93 94
   */
  public function setSitePath($path);

  /**
   * Get the site path.
   *
   * @return string
   *   The current site path.
   */
  public function getSitePath();

95 96 97 98 99 100 101
  /**
   * Gets the app root.
   *
   * @return string
   */
  public function getAppRoot();

102 103 104 105 106 107 108 109
  /**
   * Updates the kernel's list of modules to the new list.
   *
   * The kernel needs to update its bundle list and container to match the new
   * list.
   *
   * @param array $module_list
   *   The new list of modules.
110 111
   * @param array $module_filenames
   *   List of module filenames, keyed by module name.
112
   */
113
  public function updateModules(array $module_list, array $module_filenames = []);
114

115 116 117 118 119 120 121 122 123 124 125 126
  /**
   * Force a container rebuild.
   *
   * @return \Symfony\Component\DependencyInjection\ContainerInterface
   */
  public function rebuildContainer();

  /**
   * Invalidate the service container for the next request.
   */
  public function invalidateContainer();

127 128 129 130 131 132 133 134
  /**
   * Prepare the kernel for handling a request without handling the request.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The current request.
   *
   * @return $this
   *
135 136
   * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Only used by
   *   legacy front-controller scripts.
137 138 139
   */
  public function prepareLegacyRequest(Request $request);

140 141 142 143 144 145 146 147
  /**
   * Helper method that does request related initialization.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The current request.
   */
  public function preHandle(Request $request);

148 149 150 151 152
  /**
   * Helper method that loads legacy Drupal include files.
   */
  public function loadLegacyIncludes();

153
}