/** * Tests extension discovery in a virtual filesystem with vfsStream. * * @covers ::scan */ public function testExtensionDiscoveryVfs() { // Set up the file system. $filesystem = []; $files_by_type_and_name_expected = $this->populateFilesystemStructure($filesystem); $vfs = vfsStream::setup('root', NULL, $filesystem); $root = $vfs->url(); $this->assertFileExists($root . '/core/modules/system/system.module'); $this->assertFileExists($root . '/core/modules/system/system.info.yml'); // Create an ExtensionDiscovery with $root. $extension_discovery = new ExtensionDiscovery($root, FALSE, NULL, 'sites/default'); /** @var \Drupal\Core\Extension\Extension[][] $extensions_by_type */ $extensions_by_type = []; $files_by_type_and_name = []; foreach (['profile', 'module', 'theme', 'theme_engine'] as $type) { $extensions_by_type[$type] = $extension_discovery->scan($type, FALSE); foreach ($extensions_by_type[$type] as $name => $extension) { $files_by_type_and_name[$type][$name] = $extension->getPathname(); } if ($type === 'profile') { // Set profile directories for discovery of the other extension types. $extension_discovery->setProfileDirectories(['myprofile' => 'profiles/myprofile']); } } $this->assertEquals($files_by_type_and_name_expected, $files_by_type_and_name); $extension_expected = new Extension($root, 'module', 'core/modules/system/system.info.yml', 'system.module'); $extension_expected->subpath = 'modules/system'; $extension_expected->origin = 'core'; $this->assertEquals($extension_expected, $extensions_by_type['module']['system'], 'system'); $extension_expected = new Extension($root, 'theme_engine', 'core/themes/engines/twig/twig.info.yml', 'twig.engine'); $extension_expected->subpath = 'themes/engines/twig'; $extension_expected->origin = 'core'; $this->assertEquals($extension_expected, $extensions_by_type['theme_engine']['twig'], 'twig'); }
/** * Ensures that the user page is available after installation. */ public function testInstaller() { $this->assertUrl('user/1'); $this->assertResponse(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getUsername()); // @todo hmmm this message is wrong! // Verify that the confirmation message appears. require_once \Drupal::root() . '/core/includes/install.inc'; $this->assertRaw(t('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name()))); // Ensure that all modules, profile and themes have been installed and have // expected weights. $sync = \Drupal::service('config.storage.sync'); $sync_core_extension = $sync->read('core.extension'); $this->assertIdentical($sync_core_extension, \Drupal::config('core.extension')->get()); // Ensure that the correct install profile has been written to settings.php. $listing = new ExtensionDiscovery(\Drupal::root()); $listing->setProfileDirectories([]); $profiles = array_intersect_key($listing->scan('profile'), $sync_core_extension['module']); $current_profile = Settings::get('install_profile'); $this->assertFalse(empty($current_profile), 'The $install_profile setting exists'); $this->assertEqual($current_profile, key($profiles)); // Test that any configuration entities in sync have been created. // @todo }
/** * Tests that files in different directories take precedence as expected. */ function testDirectoryPrecedence() { // Define the module files we will search for, and the directory precedence // we expect. $expected_directories = array('drupal_system_listing_compatible_test' => array('core/profiles/testing/modules', 'core/modules/system/tests/modules')); // This test relies on two versions of the same module existing in // different places in the filesystem. Without that, the test has no // meaning, so assert their presence first. foreach ($expected_directories as $module => $directories) { foreach ($directories as $directory) { $filename = "{$directory}/{$module}/{$module}.info.yml"; $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename))); } } // Now scan the directories and check that the files take precedence as // expected. $listing = new ExtensionDiscovery(\Drupal::root()); $listing->setProfileDirectories(array('core/profiles/testing')); $files = $listing->scan('module'); foreach ($expected_directories as $module => $directories) { $expected_directory = array_shift($directories); $expected_uri = "{$expected_directory}/{$module}/{$module}.info.yml"; $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array('@actual' => $files[$module]->getPathname(), '@expected' => $expected_uri))); } }
/** * Returns a map of all config object names and their folders. * * The list is based on enabled modules and themes. The active configuration * storage is used rather than \Drupal\Core\Extension\ModuleHandler and * \Drupal\Core\Extension\ThemeHandler in order to resolve circular * dependencies between these services and \Drupal\Core\Config\ConfigInstaller * and \Drupal\Core\Config\TypedConfigManager. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); $install_profile = Settings::get('install_profile'); $profile = drupal_get_profile(); $extensions = $this->configStorage->read('core.extension'); // @todo Remove this scan as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); if (!empty($extensions['module'])) { $modules = $extensions['module']; // Remove the install profile as this is handled later. unset($modules[$install_profile]); $profile_list = $listing->scan('profile'); if ($profile && isset($profile_list[$profile])) { // Prime the drupal_get_filename() static cache with the profile info // file location so we can use drupal_get_path() on the active profile // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); } $module_list_scan = $listing->scan('module'); $module_list = array(); foreach (array_keys($modules) as $module) { if (isset($module_list_scan[$module])) { $module_list[$module] = $module_list_scan[$module]; } } $this->folders += $this->getComponentNames($module_list); } if (!empty($extensions['theme'])) { $theme_list_scan = $listing->scan('theme'); foreach (array_keys($extensions['theme']) as $theme) { if (isset($theme_list_scan[$theme])) { $theme_list[$theme] = $theme_list_scan[$theme]; } } $this->folders += $this->getComponentNames($theme_list); } if ($this->includeProfile) { // The install profile can override module default configuration. We do // this by replacing the config file path from the module/theme with the // install profile version if there are any duplicates. if (isset($profile)) { if (!isset($profile_list)) { $profile_list = $listing->scan('profile'); } if (isset($profile_list[$profile])) { $profile_folders = $this->getComponentNames(array($profile_list[$profile])); $this->folders = $profile_folders + $this->folders; } } } } return $this->folders; }
/** * {@inheritdoc} */ protected function getAllFolders() { if (!isset($this->folders)) { $listing = new ExtensionDiscovery(\Drupal::root()); $modules = $listing->scan('module'); $this->folders = $this->getComponentNames(array('behat_test' => $modules['behat_test'])); } return $this->folders; }
protected function setUp() { parent::setUp(); // Theme settings rely on System module's system.theme.global configuration. $this->installConfig(array('system')); if (!isset($this->availableThemes)) { $discovery = new ExtensionDiscovery(\Drupal::root()); $this->availableThemes = $discovery->scan('theme'); } }
/** * {@inheritdoc} */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = $this->getCoreNames(); $listing = new ExtensionDiscovery(\Drupal::root()); $listing->setProfileDirectories(array()); $this->folders += $this->getComponentNames($listing->scan('profile')); $this->folders += $this->getComponentNames($listing->scan('module')); $this->folders += $this->getComponentNames($listing->scan('theme')); } return $this->folders; }
/** * {@inheritdoc} */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = $this->getComponentNames('core', array('core')); // @todo Refactor getComponentNames() to use the extension list directly. $listing = new ExtensionDiscovery(\Drupal::root()); $listing->setProfileDirectories(array()); $this->folders += $this->getComponentNames('profile', array_keys($listing->scan('profile'))); $this->folders += $this->getComponentNames('module', array_keys($listing->scan('module'))); $this->folders += $this->getComponentNames('theme', array_keys($listing->scan('theme'))); } return $this->folders; }
/** * Tests rebuild the theme data with theme parents. */ public function testRebuildThemeDataWithThemeParents() { $this->extensionDiscovery->expects($this->at(0))->method('scan')->with('theme')->will($this->returnValue(array('test_subtheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml', 'test_subtheme.info.yml'), 'test_basetheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml', 'test_basetheme.info.yml')))); $this->extensionDiscovery->expects($this->at(1))->method('scan')->with('theme_engine')->will($this->returnValue(array('twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine')))); $this->infoParser->expects($this->at(0))->method('parse')->with($this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml')->will($this->returnCallback(function ($file) { $info_parser = new InfoParser(); return $info_parser->parse($file); })); $this->infoParser->expects($this->at(1))->method('parse')->with($this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml')->will($this->returnCallback(function ($file) { $info_parser = new InfoParser(); return $info_parser->parse($file); })); $this->moduleHandler->expects($this->once())->method('buildModuleDependencies')->will($this->returnArgument(0)); $theme_data = $this->themeHandler->rebuildThemeData(); $this->assertCount(2, $theme_data); $info_basetheme = $theme_data['test_basetheme']; $info_subtheme = $theme_data['test_subtheme']; // Ensure some basic properties. $this->assertInstanceOf('Drupal\\Core\\Extension\\Extension', $info_basetheme); $this->assertEquals('test_basetheme', $info_basetheme->getName()); $this->assertInstanceOf('Drupal\\Core\\Extension\\Extension', $info_subtheme); $this->assertEquals('test_subtheme', $info_subtheme->getName()); // Test the parent/child-theme properties. $info_subtheme->info['base theme'] = 'test_basetheme'; $info_basetheme->sub_themes = array('test_subtheme'); $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_basetheme->owner); $this->assertEquals('twig', $info_basetheme->prefix); $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_subtheme->owner); $this->assertEquals('twig', $info_subtheme->prefix); }
/** * [getModules description] * @param boolean $core Return core modules * @return array list of modules */ public function getModules($core = false) { if (null === $this->modules) { $this->modules = []; $extensionDiscover = new ExtensionDiscovery(\Drupal::root()); $moduleList = $extensionDiscover->scan('module'); foreach ($moduleList as $name => $filename) { if ($core) { array_push($this->modules, $name); } elseif (!preg_match('/^core/', $filename->getPathname())) { array_push($this->modules, $name); } } } return $this->modules; }
/** * Tests that directories matching file_scan_ignore_directories are ignored */ public function testFileScanIgnoreDirectory() { $listing = new ExtensionDiscovery(\Drupal::root(), FALSE); $listing->setProfileDirectories(array('core/profiles/testing')); $files = $listing->scan('module'); $this->assertArrayHasKey('drupal_system_listing_compatible_test', $files); // Reset the static to force a rescan of the directories. $reflected_class = new \ReflectionClass(ExtensionDiscovery::class); $reflected_property = $reflected_class->getProperty('files'); $reflected_property->setAccessible(TRUE); $reflected_property->setValue($reflected_class, []); $this->setSetting('file_scan_ignore_directories', ['drupal_system_listing_compatible_test']); $listing = new ExtensionDiscovery(\Drupal::root(), FALSE); $listing->setProfileDirectories(array('core/profiles/testing')); $files = $listing->scan('module'); $this->assertArrayNotHasKey('drupal_system_listing_compatible_test', $files); }
/** * Enables modules for this test. */ protected function enableModules(array $modules) { // Perform an ExtensionDiscovery scan as this function may receive a // profile that is not the current profile, and we don't yet have a cached // way to receive inactive profile information. // @todo Remove as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); $module_list = $listing->scan('module'); // In ModuleHandlerTest we pass in a profile as if it were a module. $module_list += $listing->scan('profile'); // Set the list of modules in the extension handler. $module_handler = $this->container->get('module_handler'); // Write directly to active storage to avoid early instantiation of // the event dispatcher which can prevent modules from registering events. $active_storage = $this->container->get('config.storage'); $extension_config = $active_storage->read('core.extension'); foreach ($modules as $module) { if ($module_handler->moduleExists($module)) { throw new \LogicException("{$module} module is already enabled."); } $module_handler->addModule($module, $module_list[$module]->getPath()); // Maintain the list of enabled modules in configuration. $extension_config['module'][$module] = 0; } $active_storage->write('core.extension', $extension_config); // Update the kernel to make their services available. $extensions = $module_handler->getModuleList(); $this->container->get('kernel')->updateModules($extensions, $extensions); // Ensure isLoaded() is TRUE in order to make // \Drupal\Core\Theme\ThemeManagerInterface::render() work. // Note that the kernel has rebuilt the container; this $module_handler is // no longer the $module_handler instance from above. $module_handler = $this->container->get('module_handler'); $module_handler->reload(); foreach ($modules as $module) { if (!$module_handler->moduleExists($module)) { throw new \RuntimeException("{$module} module is not enabled after enabling it."); } } }
protected function setUp() { parent::setUp(); // Install all available non-testing themes. $listing = new ExtensionDiscovery(\Drupal::root()); $this->themes = $listing->scan('theme', FALSE); \Drupal::service('theme_handler')->install(array_keys($this->themes)); // Create a test user. $this->user = $this->drupalCreateUser(array('access content', 'access user profiles')); $this->user->name = $this->xssLabel; $this->user->save(); $this->drupalLogin($this->user); // Create a test term. $this->term = entity_create('taxonomy_term', array('name' => $this->xssLabel, 'vid' => 1)); $this->term->save(); // Add a comment field. $this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN); // Create a test node tagged with the test term. $this->node = $this->drupalCreateNode(array('title' => $this->xssLabel, 'type' => 'article', 'promote' => NODE_PROMOTED, 'field_tags' => array(array('target_id' => $this->term->id())))); // Create a test comment on the test node. $this->comment = entity_create('comment', array('entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, 'subject' => $this->xssLabel, 'comment_body' => array($this->randomMachineName()))); $this->comment->save(); }
/** * Returns a map of all config object names and their folders. * * The list is based on installed modules and themes. The active * configuration storage is used rather than * \Drupal\Core\Extension\ModuleHandler and * \Drupal\Core\Extension\ThemeHandler in order to resolve circular * dependencies between these services and * \Drupal\Core\Config\ConfigInstaller and * \Drupal\Core\Config\TypedConfigManager. * * NOTE: This code is copied from ExtensionInstallStorage::getAllFolders() with * the following changes (Notes in CHANGED below) * - Load all modules whether installed or not * * @return array * An array mapping config object names with directories. */ public function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); $install_profile = Settings::get('install_profile'); $profile = drupal_get_profile(); $extensions = $this->configStorage->read('core.extension'); // @todo Remove this scan as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); // CHANGED START: Add profile directories for any bundles that use a profile. $profile_directories = []; if ($profile) { $profile_directories[] = drupal_get_path('profile', $profile); } if ($this->includeProfile) { // Add any profiles used in bundles. /** @var \Drupal\features\FeaturesAssignerInterface $assigner */ $assigner = \Drupal::service('features_assigner'); $bundles = $assigner->getBundleList(); foreach ($bundles as $bundle_name => $bundle) { if ($bundle->isProfile()) { // Register the profile directory. $profile_directory = 'profiles/' . $bundle->getProfileName(); if (is_dir($profile_directory)) { $profile_directories[] = $profile_directory; } } } } $listing->setProfileDirectories($profile_directories); // CHANGED END if (!empty($extensions['module'])) { // CHANGED START: Find ANY modules, not just installed ones. //$modules = $extensions['module']; $module_list_scan = $listing->scan('module'); $modules = $module_list_scan; // CHANGED END // Remove the install profile as this is handled later. unset($modules[$install_profile]); $profile_list = $listing->scan('profile'); if ($profile && isset($profile_list[$profile])) { // Prime the drupal_get_filename() static cache with the profile info // file location so we can use drupal_get_path() on the active profile // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); } $module_list = array(); foreach (array_keys($module_list_scan) as $module) { if (isset($module_list_scan[$module])) { $module_list[$module] = $module_list_scan[$module]; } } $this->folders += $this->getComponentNames($module_list); } if (!empty($extensions['theme'])) { $theme_list_scan = $listing->scan('theme'); foreach (array_keys($extensions['theme']) as $theme) { if (isset($theme_list_scan[$theme])) { $theme_list[$theme] = $theme_list_scan[$theme]; } } $this->folders += $this->getComponentNames($theme_list); } if ($this->includeProfile) { // The install profile can override module default configuration. We do // this by replacing the config file path from the module/theme with the // install profile version if there are any duplicates. if (isset($profile)) { if (!isset($profile_list)) { $profile_list = $listing->scan('profile'); } if (isset($profile_list[$profile])) { $profile_folders = $this->getComponentNames(array($profile_list[$profile])); $this->folders = $profile_folders + $this->folders; } } } } return $this->folders; }
/** * Scans all module + profile extensions and load the update files. */ protected function scanExtensionsAndLoadUpdateFiles() { // Scan the module list. $extension_discovery = new ExtensionDiscovery($this->root, FALSE, [], $this->sitePath); $module_extensions = $extension_discovery->scan('module'); $profile_extensions = $extension_discovery->scan('profile'); $extensions = array_merge($module_extensions, $profile_extensions); $this->loadUpdateFiles($extensions); }
/** * Enables modules for this test. * * @param array $modules * A list of modules to enable. Dependencies are not resolved; i.e., * multiple modules have to be specified with dependent modules first. * The new modules are only added to the active module list and loaded. */ protected function enableModules(array $modules) { // Perform an ExtensionDiscovery scan as this function may receive a // profile that is not the current profile, and we don't yet have a cached // way to receive inactive profile information. // @todo Remove as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); $module_list = $listing->scan('module'); // In ModuleHandlerTest we pass in a profile as if it were a module. $module_list += $listing->scan('profile'); // Set the list of modules in the extension handler. $module_handler = $this->container->get('module_handler'); // Write directly to active storage to avoid early instantiation of // the event dispatcher which can prevent modules from registering events. $active_storage = \Drupal::service('config.storage'); $extensions = $active_storage->read('core.extension'); foreach ($modules as $module) { $module_handler->addModule($module, $module_list[$module]->getPath()); // Maintain the list of enabled modules in configuration. $extensions['module'][$module] = 0; } $active_storage->write('core.extension', $extensions); // Update the kernel to make their services available. $module_filenames = $module_handler->getModuleList(); $this->kernel->updateModules($module_filenames, $module_filenames); // Ensure isLoaded() is TRUE in order to make _theme() work. // Note that the kernel has rebuilt the container; this $module_handler is // no longer the $module_handler instance from above. $this->container->get('module_handler')->reload(); $this->pass(format_string('Enabled modules: %modules.', array('%modules' => implode(', ', $modules)))); }
/** * Returns all available extensions. * * @return \Drupal\Core\Extension\Extension[] * An array of Extension objects, keyed by extension name. */ protected function getExtensions() { $listing = new ExtensionDiscovery(DRUPAL_ROOT); // Ensure that tests in all profiles are discovered. $listing->setProfileDirectories(array()); $extensions = $listing->scan('module', TRUE); $extensions += $listing->scan('profile', TRUE); $extensions += $listing->scan('theme', TRUE); return $extensions; }
/** * Returns a map of all config object names and their folders. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); // Perform an ExtensionDiscovery scan as we cannot use drupal_get_path() // yet because the system module may not yet be enabled during install. // @todo Remove as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); if ($profile = drupal_get_profile()) { $profile_list = $listing->scan('profile'); if (isset($profile_list[$profile])) { // Prime the drupal_get_filename() static cache with the profile info // file location so we can use drupal_get_path() on the active profile // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); $this->folders += $this->getComponentNames(array($profile_list[$profile])); } } // @todo Remove as part of https://www.drupal.org/node/2186491 $this->folders += $this->getComponentNames($listing->scan('module')); $this->folders += $this->getComponentNames($listing->scan('theme')); } return $this->folders; }
/** * {@inheritdoc} */ public function getAllModules() { static $modules; if (!isset($modules)) { // ModuleHandler::getModuleDirectories() returns data only for installed // modules. system_rebuild_module_data() includes only the site's install // profile directory, while we may need to include a custom profile. // @see _system_rebuild_module_data(). $listing = new ExtensionDiscovery(\Drupal::root()); $profile_directories = []; // Register the install profile. $installed_profile = $this->drupalGetProfile(); if ($installed_profile) { $profile_directories[] = drupal_get_path('profile', $installed_profile); } if (isset($bundle) && $bundle->isProfile()) { $profile_directory = 'profiles/' . $bundle->getProfileName(); if ($bundle->getProfileName() != $installed_profile && is_dir($profile_directory)) { $profile_directories[] = $profile_directory; } } $listing->setProfileDirectories($profile_directories); // Find modules. $modules = $listing->scan('module'); // Find installation profiles. $profiles = $listing->scan('profile'); foreach ($profiles as $key => $profile) { $modules[$key] = $profile; } } return $modules; }
/** * Returns module data on the filesystem. * * @param $module * The name of the module. * * @return \Drupal\Core\Extension\Extension|bool * Returns an Extension object if the module is found, FALSE otherwise. */ protected function moduleData($module) { if (!$this->moduleData) { // First, find profiles. $listing = new ExtensionDiscovery($this->root); $listing->setProfileDirectories(array()); $all_profiles = $listing->scan('profile'); $profiles = array_intersect_key($all_profiles, $this->moduleList); // If a module is within a profile directory but specifies another // profile for testing, it needs to be found in the parent profile. $settings = $this->getConfigStorage()->read('simpletest.settings'); $parent_profile = !empty($settings['parent_profile']) ? $settings['parent_profile'] : NULL; if ($parent_profile && !isset($profiles[$parent_profile])) { // In case both profile directories contain the same extension, the // actual profile always has precedence. $profiles = array($parent_profile => $all_profiles[$parent_profile]) + $profiles; } $profile_directories = array_map(function ($profile) { return $profile->getPath(); }, $profiles); $listing->setProfileDirectories($profile_directories); // Now find modules. $this->moduleData = $profiles + $listing->scan('module'); } return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE; }
/** * Enable all core modules. */ protected function enableAllCoreModules() { $listing = new ExtensionDiscovery(\Drupal::root()); $module_list = $listing->scan('module', FALSE); /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */ $module_handler = $this->container->get('module_handler'); $module_list = array_filter(array_keys($module_list), function ($module) use($module_handler, $module_list) { return !$module_handler->moduleExists($module) && substr($module_list[$module]->getPath(), 0, 4) === 'core'; }); $this->enableModules($module_list); }
/** * {@inheritdoc} */ public function getAllModules(FeaturesBundleInterface $bundle = NULL) { // ModuleHandler::getModuleDirectories() returns data only for installed // modules. system_rebuild_module_data() includes only the site's install // profile directory, while we may need to include a custom profile. // @see _system_rebuild_module_data(). $listing = new ExtensionDiscovery(\Drupal::root()); $profile_directories = []; // Register the install profile. $installed_profile = drupal_get_profile(); if ($installed_profile) { $profile_directories[] = drupal_get_path('profile', $installed_profile); } if (isset($bundle) && $bundle->isProfile()) { $profile_directory = 'profiles/' . $bundle->getProfileName(); if ($bundle->getProfileName() != $installed_profile && is_dir($profile_directory)) { $profile_directories[] = $profile_directory; } } $listing->setProfileDirectories($profile_directories); // Find modules. $modules = $listing->scan('module'); // Find installation profiles. $profiles = $listing->scan('profile'); foreach ($profiles as $key => $profile) { $modules[$key] = $profile; } $return = array(); // Detect modules by namespace. // If namespace is provided but is empty, then match all modules. foreach ($modules as $module_name => $extension) { if ($this->isFeatureModule($extension) && (!isset($bundle) || $bundle->isDefault() || $bundle->inBundle($module_name))) { $return[$module_name] = $extension; } } return $return; }
/** * Returns a map of all config object names and their folders. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getComponentNames('core', array('core')); // @todo Refactor getComponentNames() to use the extension list directly. if ($profile = drupal_get_profile()) { $this->folders += $this->getComponentNames('profile', array($profile)); } $listing = new ExtensionDiscovery(DRUPAL_ROOT); $this->folders += $this->getComponentNames('module', array_keys($listing->scan('module'))); $this->folders += $this->getComponentNames('theme', array_keys($listing->scan('theme'))); } return $this->folders; }