InstallerKernel
class InstallerKernel extends DrupalKernel (View source)
Extend DrupalKernel to handle force some kernel behaviors.
Traits
Provides methods for checking if Drupal is already installed.
Properties
| protected string | $phpArrayDumperClass | Holds the class used for dumping the container to a PHP array. |
from DrupalKernel |
| protected array | $defaultBootstrapContainerDefinition | Holds the default bootstrap container definition. |
from DrupalKernel |
| protected string | $bootstrapContainerClass | Holds the class used for instantiating the bootstrap container. |
from DrupalKernel |
| protected ContainerInterface | $bootstrapContainer | Holds the bootstrap container. |
from DrupalKernel |
| protected ContainerInterface | $container | Holds the container instance. |
from DrupalKernel |
| protected string | $environment | The environment, e.g. 'testing', 'install'. |
from DrupalKernel |
| protected bool | $booted | Whether the kernel has been booted. |
from DrupalKernel |
| protected bool | $prepared | Whether essential services have been set up properly by preHandle(). |
from DrupalKernel |
| protected array | $moduleList | Holds the list of enabled modules. |
from DrupalKernel |
| protected Extension[] | $moduleData | List of available modules and installation profiles. |
from DrupalKernel |
| protected ClassLoader | $classLoader | The class loader object. |
from DrupalKernel |
| protected StorageInterface | $configStorage | Config storage object used for reading enabled modules configuration. |
from DrupalKernel |
| protected bool | $allowDumping | Whether the container can be dumped. |
from DrupalKernel |
| protected bool | $containerNeedsRebuild | Whether the container needs to be rebuilt the next time it is initialized. |
from DrupalKernel |
| protected bool | $containerNeedsDumping | Whether the container needs to be dumped once booting is complete. |
from DrupalKernel |
| protected array | $serviceYamls | List of discovered services.yml pathnames. |
from DrupalKernel |
| protected array | $serviceProviderClasses | List of discovered service provider class names or objects. |
from DrupalKernel |
| protected array | $serviceProviders | List of instantiated service provider classes. |
from DrupalKernel |
| static protected bool | $isEnvironmentInitialized | Whether the PHP environment has been initialized. |
from DrupalKernel |
| protected string | $sitePath | The site directory. |
from DrupalKernel |
| protected string | $root | The app root. |
from DrupalKernel |
Methods
Determines if an exception handler should redirect to the installer.
Create a DrupalKernel object from a request.
Constructs a DrupalKernel object.
Determine the application root directory based on this file's location.
Returns the appropriate site directory for a request.
Returns the cached container definition - if any.
Helper method that does request related initialization.
Returns all registered service providers.
{@inheritdoc}
Prepare the kernel for handling a request without handling the request.
Implements Drupal\Core\DrupalKernelInterface::updateModules().
Returns the container cache key based on the environment.
Initializes the service container.
Setup a consistent PHP environment.
Locate site path and initialize settings singleton.
Bootstraps the legacy global request variables.
Returns service instances to persist from an old container to a new one.
Moves persistent service instances into a new container.
Attach synthetic values on to kernel.
Gets a new ContainerBuilder instance used to build the service container.
Stores the container definition in a cache.
Returns the active configuration storage used during early install.
Returns an array of Extension class parameters for all enabled modules.
Gets the PSR-4 base directories for module namespaces.
Registers a list of namespaces with PSR-4 directories for class loading.
Validates the hostname supplied from the HTTP request.
Sets up the lists of trusted HTTP Host headers.
Gets the active install profile.
Reset the bootstrap config storage.
Returns TRUE if a Drupal installation is currently being attempted.
Details
protected bool
isCli()
Returns whether the current PHP process runs on CLI.
protected bool
shouldRedirectToInstaller(Exception $exception, Connection $connection = NULL)
Determines if an exception handler should redirect to the installer.
static DrupalKernel
createFromRequest(Request $request, $class_loader, string $environment, bool $allow_dumping = TRUE, string $app_root = NULL)
Create a DrupalKernel object from a request.
__construct(string $environment, $class_loader, bool $allow_dumping = TRUE, string $app_root = NULL)
Constructs a DrupalKernel object.
static protected string
guessApplicationRoot()
Determine the application root directory based on this file's location.
static string
findSitePath(Request $request, bool $require_settings = TRUE, string $app_root = NULL)
Returns the appropriate site directory for a request.
Once the kernel has been created DrupalKernelInterface::getSitePath() is preferred since it gets the statically cached result of this method.
Site directories contain all site specific code. This includes settings.php for bootstrap level configuration, file configuration stores, public file storage and site specific modules and themes.
A file named sites.php must be present in the sites directory for multisite. If it doesn't exist, then 'sites/default' will be used.
Finds a matching site directory file by stripping the website's hostname from left to right and pathname from right to left. By default, the directory must contain a 'settings.php' file for it to match. If the parameter $require_settings is set to FALSE, then a directory without a 'settings.php' file will match as well. The first configuration file found will be used and the remaining ones will be ignored. If no configuration file is found, returns a default value 'sites/default'. See default.settings.php for examples on how the URL is converted to a directory.
The sites.php file in the sites directory can define aliases in an
associative array named $sites. The array is written in the format
'
setSitePath(string $path)
Set the current site path.
string
getSitePath()
Get the site path.
string
getAppRoot()
Gets the app root.
$this
boot()
Boots the current kernel.
shutdown()
Shuts down the kernel.
ContainerInterface
getContainer()
Gets the current container.
setContainer(ContainerInterface $container = NULL)
{@inheritdoc}
array|null
getCachedContainerDefinition()
Returns the cached container definition - if any.
This also allows inspecting a built container for debugging purposes.
loadLegacyIncludes()
Helper method that loads legacy Drupal include files.
preHandle(Request $request)
Helper method that does request related initialization.
array
discoverServiceProviders()
Discovers available serviceProviders.
array
getServiceProviders(string $origin)
Returns all registered service providers.
terminate(Request $request, Response $response)
{@inheritdoc}
handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE)
{@inheritdoc}
protected Response
handleException(Exception $e, Request $request, int $type)
Converts an exception into a response.
$this
prepareLegacyRequest(Request $request)
Prepare the kernel for handling a request without handling the request.
protected Extension|bool
moduleData($module)
Returns module data on the filesystem.
updateModules(array $module_list, array $module_filenames = [])
Implements Drupal\Core\DrupalKernelInterface::updateModules().
protected string
getContainerCacheKey()
Returns the container cache key based on the environment.
The 'environment' consists of:
- The kernel environment string.
- The Drupal version constant.
- The deployment identifier from settings.php. This allows custom deployments to force a container rebuild.
- The operating system running PHP. This allows compiler passes to optimize services for different operating systems.
- The paths to any additional container YAMLs from settings.php.
protected array
getKernelParameters()
Returns the kernel parameters.
protected ContainerInterface
initializeContainer()
Initializes the service container.
static
bootEnvironment(string $app_root = NULL)
Setup a consistent PHP environment.
This method sets PHP environment options we want to be sure are set correctly for security or just saneness.
protected
initializeSettings(Request $request)
Locate site path and initialize settings singleton.
protected
initializeRequestGlobals(Request $request)
Bootstraps the legacy global request variables.
protected
getServicesToPersist(ContainerInterface $container)
Returns service instances to persist from an old container to a new one.
protected
persistServices(ContainerInterface $container, array $persist)
Moves persistent service instances into a new container.
ContainerInterface
rebuildContainer()
Force a container rebuild.
invalidateContainer()
Invalidate the service container for the next request.
protected ContainerInterface
attachSynthetic(ContainerInterface $container)
Attach synthetic values on to kernel.
protected ContainerBuilder
compileContainer()
Compiles a new service container.
protected
initializeServiceProviders()
Registers all service providers to the kernel.
protected ContainerBuilder
getContainerBuilder()
Gets a new ContainerBuilder instance used to build the service container.
protected bool
cacheDrupalContainer(array $container_definition)
Stores the container definition in a cache.
protected HttpKernelInterface
getHttpKernel()
Gets a http kernel from the container
StorageInterface
getConfigStorage()
Returns the active configuration storage used during early install.
This override changes the visibility so that the installer can access config storage before the container is properly built.
protected array
getModulesParameter()
Returns an array of Extension class parameters for all enabled modules.
protected array
getModuleFileNames()
Gets the file name for each enabled module.
protected string[]
getModuleNamespacesPsr4(string[] $module_file_names)
Gets the PSR-4 base directories for module namespaces.
protected
classLoaderAddMultiplePsr4(array $namespaces = [], object $class_loader = NULL)
Registers a list of namespaces with PSR-4 directories for class loading.
static protected bool
validateHostnameLength(string $host)
Validates a hostname length.
static bool
validateHostname(Request $request)
Validates the hostname supplied from the HTTP request.
static protected bool
setupTrustedHosts(Request $request, array $host_patterns)
Sets up the lists of trusted HTTP Host headers.
Since the HTTP Host header can be set by the user making the request, it is possible to create an attack vectors against a site by overriding this. Symfony provides a mechanism for creating a list of trusted Host values.
Host patterns (as regular expressions) can be configured through settings.php for multisite installations, sites using ServerAlias without canonical redirection, or configurations where the site responds to default requests. For example,
protected
addServiceFiles(array $service_yamls)
Add service files.
string|null
getInstallProfile()
Gets the active install profile.
resetConfigStorage()
Reset the bootstrap config storage.
Use this from a database driver runTasks() if the method overrides the bootstrap config storage. Normally the bootstrap config storage is not re-instantiated during a single install request. Most drivers will not need this method.
static bool
installationAttempted()
Returns TRUE if a Drupal installation is currently being attempted.