diff --git a/core/core.services.yml b/core/core.services.yml index 236ce66..fd75d30 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -287,7 +287,7 @@ services: arguments: ['@container.namespaces', '@cache.discovery', '@module_handler'] module_handler: class: Drupal\Core\Extension\ModuleHandler - arguments: ['%container.modules%', '@kernel', '@cache.bootstrap'] + arguments: ['%container.modules%', '@cache.bootstrap'] module_installer: class: Drupal\Core\Extension\ModuleInstaller arguments: ['@module_handler', '@kernel'] diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 677e52c..2ffebf3 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -65,13 +65,6 @@ class ModuleHandler implements ModuleHandlerInterface { protected $hookInfo; /** - * The drupal kernel. - * - * @var \Drupal\Core\DrupalKernelInterface - */ - protected $kernel; - - /** * Cache backend for storing module hook implementation information. * * @var \Drupal\Core\Cache\CacheBackendInterface @@ -107,7 +100,7 @@ class ModuleHandler implements ModuleHandlerInterface { * @see \Drupal\Core\DrupalKernel * @see \Drupal\Core\CoreServiceProvider */ - public function __construct(array $module_list = array(), DrupalKernelInterface $kernel, CacheBackendInterface $cache_backend) { + public function __construct(array $module_list = array(), CacheBackendInterface $cache_backend) { $this->moduleList = array(); foreach ($module_list as $name => $module) { $this->moduleList[$name] = new Extension($module['type'], $module['pathname'], $module['filename']); diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index fd519ae..7aab4a7 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Installer\Form; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; @@ -56,8 +55,8 @@ class SiteConfigureForm extends FormBase { * The user storage. * @param \Drupal\Core\State\StateInterface $state * The state service. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_installer - * The module handler. + * @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer + * The module installer. * @param \Drupal\Core\Locale\CountryManagerInterface $country_manager * The country manager. */ diff --git a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php index dccdad8..d2974b3 100644 --- a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php @@ -16,7 +16,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; /** * Builds a confirmation form to uninstall selected modules. diff --git a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php index 6a451cc..1d382c7 100644 --- a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php @@ -310,16 +310,14 @@ function testUninstallNotInstalled() { function testThemeInfoAlter() { $name = 'seven'; $this->container->get('state')->set('module_test.hook_system_info_alter', TRUE); - $module_handler = $this->container->get('module_handler'); - $module_installer = $this->container->get('module_installer'); $this->themeHandler()->install(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name]->info['regions']['test_region'])); - $module_installer->install(array('module_test'), FALSE); - $this->assertTrue($module_handler->moduleExists('module_test')); + $this->moduleInstaller()->install(array('module_test'), FALSE); + $this->assertTrue($this->moduleHandler()->moduleExists('module_test')); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name]->info['regions']['test_region'])); @@ -334,8 +332,8 @@ function testThemeInfoAlter() { $system_list = system_list('theme'); $this->assertTrue(isset($system_list[$name]->info['regions']['test_region'])); - $module_installer->uninstall(array('module_test')); - $this->assertFalse($module_handler->moduleExists('module_test')); + $this->moduleInstaller()->uninstall(array('module_test')); + $this->assertFalse($this->moduleHandler()->moduleExists('module_test')); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name]->info['regions']['test_region'])); @@ -390,4 +388,22 @@ protected function configStorage() { return $this->container->get('config.storage'); } + /** + * Returns the ModuleHandler. + * + * @return \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected function moduleHandler() { + return $this->container->get('module_handler'); + } + + /** + * Returns the ModuleInstaller. + * + * @return \Drupal\Core\Extension\ModuleInstallerInterface + */ + protected function moduleInstaller() { + return $this->container->get('module_installer'); + } + } diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php index 493e201..9e8b07e 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php @@ -18,13 +18,6 @@ class ModuleHandlerTest extends UnitTestCase { /** - * The mocked drupal kernel. - * - * @var \Drupal\Core\DrupalKernelInterface - */ - protected $kernel; - - /** * The mocked cache backend. * * @var \Drupal\Core\Cache\CacheBackendInterface|\PHPUnit_Framework_MockObject_MockObject @@ -44,7 +37,6 @@ class ModuleHandlerTest extends UnitTestCase { * @covers ::__construct */ protected function setUp() { - $this->kernel = $this->getMock('Drupal\Core\DrupalKernelInterface'); $this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $this->moduleHandler = new ModuleHandler(array( 'module_handler_test' => array( @@ -52,7 +44,7 @@ protected function setUp() { 'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', 'filename' => 'module_handler_test.module', ) - ), $this->kernel, $this->cacheBackend); + ), $this->cacheBackend); } /** @@ -103,7 +95,7 @@ public function testModuleReloading() { 'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', 'filename' => 'module_handler_test.module', ) - ), $this->kernel, $this->cacheBackend + ), $this->cacheBackend )) ->setMethods(array('load')) ->getMock(); @@ -171,7 +163,7 @@ public function testGetModuleWithNonExistingModule() { public function testSetModuleList() { $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler') ->setConstructorArgs(array( - array(), $this->kernel, $this->cacheBackend + array(), $this->cacheBackend )) ->setMethods(array('resetImplementations')) ->getMock(); @@ -199,7 +191,7 @@ public function testAddModule() { $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler') ->setConstructorArgs(array( - array(), $this->kernel, $this->cacheBackend + array(), $this->cacheBackend )) ->setMethods(array('resetImplementations')) ->getMock(); @@ -221,7 +213,7 @@ public function testAddProfile() { $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler') ->setConstructorArgs(array( - array(), $this->kernel, $this->cacheBackend + array(), $this->cacheBackend )) ->setMethods(array('resetImplementations')) ->getMock(); @@ -257,7 +249,7 @@ public function testLoadAllIncludes() { 'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', 'filename' => 'module_handler_test.module', ) - ), $this->kernel, $this->cacheBackend + ), $this->cacheBackend )) ->setMethods(array('loadInclude')) ->getMock(); @@ -338,7 +330,7 @@ public function testCachedGetImplementations() { 'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', 'filename' => 'module_handler_test.module', ) - ), $this->kernel, $this->cacheBackend + ), $this->cacheBackend )) ->setMethods(array('buildImplementationInfo', 'loadInclude')) ->getMock(); @@ -373,7 +365,7 @@ public function testCachedGetImplementationsMissingMethod() { 'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', 'filename' => 'module_handler_test.module', ) - ), $this->kernel, $this->cacheBackend + ), $this->cacheBackend )) ->setMethods(array('buildImplementationInfo')) ->getMock();