// up the new module, since it merges the installation status of modules
// into its statically cached list.
\Drupal::
service('extension.list.module'
)->
reset();
// Update the kernel to include it.
$this->
updateKernel($module_filenames);
// Load the module's .module and .install files.
$this->moduleHandler->
load($module);
$this->moduleHandler->
loadInclude($module, 'install'
);
if (!InstallerKernel::
installationAttempted()) { // Replace the route provider service with a version that will rebuild
// if routes used during installation. This ensures that a module's
// routes are available during installation. This has to occur before
// any services that depend on it are instantiated otherwise those
// services will have the old route provider injected. Note that, since
// the container is rebuilt by updating the kernel, the route provider
// service is the regular one even though we are in a loop and might
// have replaced it before.
\Drupal::
getContainer()->
set('router.route_provider.old', \Drupal::
service('router.route_provider'
));
\Drupal::
getContainer()->
set('router.route_provider', \Drupal::
service('router.route_provider.lazy_builder'
));
}