diff --git a/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php index 6d7ae6c1ea..4b7371c869 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ExtensionList.php @@ -210,8 +210,8 @@ protected function getPathnamesCacheId() { * TRUE if the extension exists (regardless installed or not) and FALSE if * not. */ - public function extensionExists($extension_name) { - $extensions = $this->listExtensions(); + public function exists($extension_name) { + $extensions = $this->list(); return isset($extensions[$extension_name]); } @@ -228,7 +228,7 @@ public function extensionExists($extension_name) { * If there is no extension with the supplied extension human name. */ public function getName($extension_name) { - return $this->getExtension($extension_name)->info['name']; + return $this->get($extension_name)->info['name']; } /** @@ -243,8 +243,8 @@ public function getName($extension_name) { * @throws \InvalidArgumentException * If there is no extension with the supplied name. */ - public function getExtension($extension_name) { - $extensions = $this->listExtensions(); + public function get($extension_name) { + $extensions = $this->list(); if (isset($extensions[$extension_name])) { return $extensions[$extension_name]; } @@ -258,7 +258,7 @@ public function getExtension($extension_name) { * @return \Drupal\Core\Extension\Extension[] * Processed extension objects, keyed by extension machine name. */ - public function listExtensions() { + public function list() { if ($this->extensions !== NULL) { return $this->extensions; } @@ -266,7 +266,7 @@ public function listExtensions() { $this->extensions = $cache->data; return $this->extensions; } - $extensions = $this->doListExtensions(); + $extensions = $this->doList(); $this->cache->set($this->getListCacheId(), $extensions); $this->extensions = $extensions; return $this->extensions; @@ -294,7 +294,7 @@ protected function doScanExtensions() { * @throws \Drupal\Core\Extension\InfoParserException * If one of the .info.yml files is incomplete, or causes a parsing error. */ - protected function doListExtensions() { + protected function doList() { // Find extensions. $extensions = $this->doScanExtensions(); @@ -398,7 +398,7 @@ public function getAllInstalledInfo() { protected function recalculateInfo() { return array_map(function (Extension $extension) { return $extension->info; - }, $this->listExtensions()); + }, $this->list()); } /** @@ -432,7 +432,7 @@ public function getPathnames() { * An array of .info.yml file locations keyed by the extension machine name. */ protected function recalculatePathnames() { - $extensions = $this->listExtensions(); + $extensions = $this->list(); ksort($extensions); return array_map(function (Extension $extension) { @@ -519,6 +519,9 @@ public function getPathname($extension_name) { /** * Gets the path to an extension of a specific type (module, theme, etc.). + * + * The path is the directory in which the .info file is located. This name is + * coming from \SplFileInfo. * * @param string $extension_name * The name of the extension for which the path is requested. diff --git a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php index 00f154bc91..57198fea5f 100644 --- a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php @@ -127,7 +127,7 @@ protected function getProfileDirectories(ExtensionDiscovery $discovery) { * The active profile, if there is one. */ protected function getActiveProfile() { - $profiles = $this->profileList->listExtensions(); + $profiles = $this->profileList->list(); if ($this->installProfile && isset($profiles[$this->installProfile])) { return $profiles[$this->installProfile]; } @@ -155,9 +155,9 @@ protected function doScanExtensions() { /** * {@inheritdoc} */ - protected function doListExtensions() { + protected function doList() { // Find modules. - $extensions = parent::doListExtensions(); + $extensions = parent::doList(); // It is possible that a module was marked as required by // hook_system_info_alter() and modules that it depends on are not required. foreach ($extensions as $extension) { diff --git a/core/lib/Drupal/Core/Updater/Module.php b/core/lib/Drupal/Core/Updater/Module.php index 0eaf46c634..35232b3c0d 100644 --- a/core/lib/Drupal/Core/Updater/Module.php +++ b/core/lib/Drupal/Core/Updater/Module.php @@ -49,7 +49,9 @@ public static function getRootDirectoryRelativePath() { public function isInstalled() { // Check if the module exists in the file system, regardless of whether it // is enabled or not. - return \Drupal::service('extension.list.module')->extensionExists($this->name); + /** @var \Drupal\Core\Extension\ExtensionList $module_extension_list */ + $module_extension_list = \Drupal::service('extension.list.module'); + return $module_extension_list->exists($this->name); } /** diff --git a/core/modules/book/tests/src/Kernel/BookUninstallTest.php b/core/modules/book/tests/src/Kernel/BookUninstallTest.php index 279873481b..817b1335c1 100644 --- a/core/modules/book/tests/src/Kernel/BookUninstallTest.php +++ b/core/modules/book/tests/src/Kernel/BookUninstallTest.php @@ -76,7 +76,7 @@ public function testBookUninstall() { $book_node->delete(); // No nodes exist therefore the book module is not required. - $module_data = \Drupal::service('extension.list.module')->reset()->listExtensions(); + $module_data = \Drupal::service('extension.list.module')->reset()->list(); $this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.'); $node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]); diff --git a/core/modules/filter/tests/src/Kernel/FilterAPITest.php b/core/modules/filter/tests/src/Kernel/FilterAPITest.php index 6b3eee0db0..ed2db2f343 100644 --- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php @@ -485,7 +485,7 @@ public function testDependencyRemoval() { drupal_static_reset('filter_formats'); \Drupal::entityManager()->getStorage('filter_format')->resetCache(); - $module_data = \Drupal::service('extension.list.module')->reset()->listExtensions(); + $module_data = \Drupal::service('extension.list.module')->reset()->list(); $this->assertFalse(isset($module_data['filter_test']->info['required']), 'The filter_test module is required.'); // Verify that a dependency exists on the module that provides the filter diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 075cc803e8..115635198f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1006,12 +1006,12 @@ function _system_rebuild_module_data_ensure_required($module, &$modules) { * An associative array of module information. * * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. - * Use \Drupal::service('extension.list.module')->reset()->listExtensions() + * Use \Drupal::service('extension.list.module')->reset()->list() * instead. Note: You probably don't need the reset() method. */ function _system_rebuild_module_data() { - @trigger_error("_system_rebuild_module_data() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->listExtensions(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); - return \Drupal::service('extension.list.module')->reset()->listExtensions(); + @trigger_error("_system_rebuild_module_data() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->list(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); + return \Drupal::service('extension.list.module')->reset()->list(); } /** @@ -1023,8 +1023,8 @@ function _system_rebuild_module_data() { * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. */ function system_rebuild_module_data() { - @trigger_error("system_rebuild_module_data() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->listExtensions(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); - return \Drupal::service('extension.list.module')->reset()->listExtensions(); + @trigger_error("system_rebuild_module_data() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->list(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); + return \Drupal::service('extension.list.module')->reset()->list(); } /** diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 59382d72a5..dcad79ee13 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -182,7 +182,7 @@ public function testUninstallProfileDependency() { drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml'); $this->enableModules(['module_test', $profile]); - $data = \Drupal::service('extension.list.module')->reset()->listExtensions(); + $data = \Drupal::service('extension.list.module')->reset()->list(); $this->assertTrue(isset($data[$profile]->requires[$dependency])); $this->moduleInstaller()->install([$dependency]); diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php index 70512c644e..c40fcee98a 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php @@ -12,9 +12,9 @@ class ModuleExtensionListTest extends KernelTestBase { /** - * @covers ::listExtensions + * @covers ::list */ - public function testListExtensions() { + public function testlist() { $settings = Settings::getAll(); $settings['install_profile'] = 'testing'; new Settings($settings); @@ -29,7 +29,7 @@ public function testListExtensions() { /** @var \Drupal\Core\Extension\ModuleExtensionList $module_extension_list */ $module_extension_list = \Drupal::service('extension.list.module'); - $extensions = $module_extension_list->listExtensions(); + $extensions = $module_extension_list->list(); $this->assertArrayHasKey('testing', $extensions); $this->assertEquals(1000, $extensions['testing']->weight); diff --git a/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php b/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php index da4b322a14..c50be34488 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php @@ -56,7 +56,7 @@ public function testGetExtensionWithNonExistingExtension() { $test_extension_list->setExtensionDiscovery($extension_discovery->reveal()); $this->setExpectedException(\InvalidArgumentException::class); - $test_extension_list->getExtension('test_name'); + $test_extension_list->get('test_name'); } /** @@ -65,18 +65,18 @@ public function testGetExtensionWithNonExistingExtension() { public function testGetExtension() { $test_extension_list = $this->setupTestExtensionList(); - $extension = $test_extension_list->getExtension('test_name'); + $extension = $test_extension_list->get('test_name'); $this->assertInstanceOf(Extension::class, $extension); $this->assertEquals('test_name', $extension->getName()); } /** - * @covers ::listExtensions + * @covers ::list */ - public function testListExtensions() { + public function testList() { $test_extension_list = $this->setupTestExtensionList(); - $extensions = $test_extension_list->listExtensions(); + $extensions = $test_extension_list->list(); $this->assertCount(1, $extensions); $this->assertEquals('test_name', $extensions['test_name']->getName()); }