function ExtensionInstallStorage::getAllFolders

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/ExtensionInstallStorage.php \Drupal\Core\Config\ExtensionInstallStorage::getAllFolders()
  2. 8.9.x core/lib/Drupal/Core/Config/ExtensionInstallStorage.php \Drupal\Core\Config\ExtensionInstallStorage::getAllFolders()
  3. 11.x core/lib/Drupal/Core/Config/ExtensionInstallStorage.php \Drupal\Core\Config\ExtensionInstallStorage::getAllFolders()

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 value

array An array mapping config object names with directories.

Overrides InstallStorage::getAllFolders

File

core/lib/Drupal/Core/Config/ExtensionInstallStorage.php, line 86

Class

ExtensionInstallStorage
Storage to access configuration and schema in enabled extensions.

Namespace

Drupal\Core\Config

Code

protected function getAllFolders() {
    if (!isset($this->folders)) {
        $this->folders = [];
        $this->folders += $this->getCoreNames();
        $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[$this->installProfile]);
            $profile_list = $listing->scan('profile');
            if ($this->installProfile && isset($profile_list[$this->installProfile])) {
                // Prime the \Drupal\Core\Extension\ExtensionList::getPathname()
                // static cache with the profile info file location so we can use
                // ExtensionList::getPath() on the active profile during the module
                // scan.
                // @todo Remove as part of https://www.drupal.org/node/2186491
                
                /** @var \Drupal\Core\Extension\ProfileExtensionList $profile_extension_list */
                $profile_extension_list = \Drupal::service('extension.list.profile');
                $profile_extension_list->setPathname($this->installProfile, $profile_list[$this->installProfile]
                    ->getPathname());
            }
            $module_list_scan = $listing->scan('module');
            $module_list = [];
            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 ($this->installProfile) {
                if (!isset($profile_list)) {
                    $profile_list = $listing->scan('profile');
                }
                if (isset($profile_list[$this->installProfile])) {
                    $profile_folders = $this->getComponentNames([
                        $profile_list[$this->installProfile],
                    ]);
                    $this->folders = $profile_folders + $this->folders;
                }
            }
        }
    }
    return $this->folders;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.