diff --cc core/core.services.yml index b0fdda0,1c898cb..0000000 --- a/core/core.services.yml +++ b/core/core.services.yml @@@ -288,10 -287,13 +288,13 @@@ services arguments: ['@container.namespaces', '@cache.discovery', '@module_handler'] module_handler: class: Drupal\Core\Extension\ModuleHandler - arguments: ['@app.root', '%container.modules%', '@kernel', '@cache.bootstrap'] - arguments: ['%container.modules%', '@cache.bootstrap'] ++ arguments: ['@app.root', '%container.modules%', '@cache.bootstrap'] + module_installer: + class: Drupal\Core\Extension\ModuleInstaller + arguments: ['@module_handler', '@kernel'] theme_handler: class: Drupal\Core\Extension\ThemeHandler - arguments: ['@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder_indicator'] + arguments: ['@app.root', '@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder_indicator'] entity.manager: class: Drupal\Core\Entity\EntityManager arguments: ['@container.namespaces', '@module_handler', '@cache.discovery', '@language_manager', '@string_translation', '@class_resolver', '@typed_data_manager', '@entity.definitions.installed', '@event_dispatcher'] diff --cc core/lib/Drupal/Core/Extension/ModuleHandler.php index 12d2805,2ffebf3..0000000 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@@ -8,11 -8,11 +8,9 @@@ namespace Drupal\Core\Extension; use Drupal\Component\Graph\Graph; --use Drupal\Component\Serialization\Yaml; use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\String; use Drupal\Core\Cache\CacheBackendInterface; --use Drupal\Core\DrupalKernelInterface; /** * Class that manages modules in a Drupal installation. @@@ -108,21 -92,19 +99,18 @@@ class ModuleHandler implements ModuleHa * An associative array whose keys are the names of installed modules and * whose values are Extension class parameters. This is normally the * %container.modules% parameter being set up by DrupalKernel. -- * @param \Drupal\Core\DrupalKernelInterface $kernel -- * The drupal kernel. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * Cache backend for storing module hook implementation information. * * @see \Drupal\Core\DrupalKernel * @see \Drupal\Core\CoreServiceProvider */ - public function __construct($root, array $module_list = array(), DrupalKernelInterface $kernel, CacheBackendInterface $cache_backend) { - public function __construct(array $module_list = array(), CacheBackendInterface $cache_backend) { ++ public function __construct($root, array $module_list = array(), CacheBackendInterface $cache_backend) { + $this->root = $root; $this->moduleList = array(); foreach ($module_list as $name => $module) { - $this->moduleList[$name] = new Extension($module['type'], $module['pathname'], $module['filename']); + $this->moduleList[$name] = new Extension($this->root, $module['type'], $module['pathname'], $module['filename']); } - $this->kernel = $kernel; $this->cacheBackend = $cache_backend; } diff --cc core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 05c9c23,7aab4a7..0000000 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@@ -69,11 -60,10 +69,11 @@@ class SiteConfigureForm extends FormBas * @param \Drupal\Core\Locale\CountryManagerInterface $country_manager * The country manager. */ - public function __construct($root, UserStorageInterface $user_storage, StateInterface $state, ModuleHandlerInterface $module_handler, CountryManagerInterface $country_manager) { - public function __construct(UserStorageInterface $user_storage, StateInterface $state, ModuleInstallerInterface $module_installer, CountryManagerInterface $country_manager) { ++ public function __construct($root, UserStorageInterface $user_storage, StateInterface $state, ModuleInstallerInterface $module_installer, CountryManagerInterface $country_manager) { + $this->root = $root; $this->userStorage = $user_storage; $this->state = $state; - $this->moduleHandler = $module_handler; + $this->moduleInstaller = $module_installer; $this->countryManager = $country_manager; } @@@ -82,10 -72,9 +82,10 @@@ */ public static function create(ContainerInterface $container) { return new static( + $container->get('app.root'), $container->get('entity.manager')->getStorage('user'), $container->get('state'), - $container->get('module_handler'), + $container->get('module_installer'), $container->get('country_manager') ); } diff --cc core/modules/system/src/Tests/Plugin/PluginTestBase.php index 618c4ef,94e6ad8..0000000 --- a/core/modules/system/src/Tests/Plugin/PluginTestBase.php +++ b/core/modules/system/src/Tests/Plugin/PluginTestBase.php @@@ -47,7 -47,7 +47,7 @@@ abstract class PluginTestBase extends K // as derivatives and ReflectionFactory. $this->testPluginManager = new TestPluginManager(); $this->mockBlockManager = new MockBlockManager(); - $module_handler = new ModuleHandler(\Drupal::root(), array(), $this->container->get('kernel'), new MemoryBackend('plugin')); - $module_handler = new ModuleHandler(array(), new MemoryBackend('plugin'), $this->container->get('event_dispatcher')); ++ $module_handler = new ModuleHandler(\Drupal::root(), array(), new MemoryBackend('plugin'), $this->container->get('event_dispatcher')); $this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler); // The expected plugin definitions within each manager. Several tests assert diff --cc core/modules/taxonomy/src/Tests/VocabularyCrudTest.php index f265ec2,ffe5213..0000000 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@@ -193,9 -193,9 +193,9 @@@ class VocabularyCrudTest extends Taxono ); entity_create('field_config', $field_definition)->save(); - require_once DRUPAL_ROOT . '/core/includes/install.inc'; + require_once \Drupal::root() . '/core/includes/install.inc'; - $this->container->get('module_handler')->uninstall(array('taxonomy')); - \Drupal::moduleHandler()->install(array('taxonomy')); + $this->container->get('module_installer')->uninstall(array('taxonomy')); + $this->container->get('module_installer')->install(array('taxonomy')); // Now create a vocabulary with the same name. All fields // connected to this vocabulary name should have been removed when the diff --cc core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php index fe5b6e0,9e8b07e..0000000 --- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php @@@ -44,12 -37,8 +37,10 @@@ class ModuleHandlerTest extends UnitTes * @covers ::__construct */ protected function setUp() { + parent::setUp(); + - $this->kernel = $this->getMock('Drupal\Core\DrupalKernelInterface'); - $this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); - $this->moduleHandler = new ModuleHandler(array( + $this->moduleHandler = new ModuleHandler($this->root, array( 'module_handler_test' => array( 'type' => 'module', 'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', @@@ -175,7 -163,7 +166,7 @@@ public function testSetModuleList() { $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler') ->setConstructorArgs(array( - $this->root, array(), $this->kernel, $this->cacheBackend - array(), $this->cacheBackend ++ $this->root, array(), $this->cacheBackend )) ->setMethods(array('resetImplementations')) ->getMock(); @@@ -203,7 -191,7 +194,7 @@@ $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler') ->setConstructorArgs(array( - $this->root, array(), $this->kernel, $this->cacheBackend - array(), $this->cacheBackend ++ $this->root, array(), $this->cacheBackend )) ->setMethods(array('resetImplementations')) ->getMock(); @@@ -225,7 -213,7 +216,7 @@@ $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler') ->setConstructorArgs(array( - $this->root, array(), $this->kernel, $this->cacheBackend - array(), $this->cacheBackend ++ $this->root, array(), $this->cacheBackend )) ->setMethods(array('resetImplementations')) ->getMock(); diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index f5e3c2d..c9308fb 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -27,8 +27,22 @@ class ModuleInstaller implements ModuleInstallerInterface { protected $moduleHandler; /** + * The drupal kernel. + * + * @var \Drupal\Core\DrupalKernelInterface + */ + protected $kernel; + + /** + * Constructs a new ModuleInstaller instance. + * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. + * @param \Drupal\Core\DrupalKernelInterface $kernel + * The drupal kernel. + * + * @see \Drupal\Core\DrupalKernel + * @see \Drupal\Core\CoreServiceProvider */ public function __construct(ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel) { $this->moduleHandler = $module_handler;