function ExtensionDiscovery::setProfileDirectoriesFromSettings

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Extension/ExtensionDiscovery.php \Drupal\Core\Extension\ExtensionDiscovery::setProfileDirectoriesFromSettings()
  2. 8.9.x core/lib/Drupal/Core/Extension/ExtensionDiscovery.php \Drupal\Core\Extension\ExtensionDiscovery::setProfileDirectoriesFromSettings()
  3. 11.x core/lib/Drupal/Core/Extension/ExtensionDiscovery.php \Drupal\Core\Extension\ExtensionDiscovery::setProfileDirectoriesFromSettings()

Sets installation profile directories based on current site settings.

Return value

$this

1 call to ExtensionDiscovery::setProfileDirectoriesFromSettings()
ExtensionDiscovery::scan in core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
Discovers available extensions of a given type.

File

core/lib/Drupal/Core/Extension/ExtensionDiscovery.php, line 229

Class

ExtensionDiscovery
Discovers available extensions in the filesystem.

Namespace

Drupal\Core\Extension

Code

public function setProfileDirectoriesFromSettings() {
  $this->profileDirectories = [];
  // This method may be called by the database system early in bootstrap
  // before the container is initialized. In that case, the parameter is not
  // accessible yet, hence return.
  if (!\Drupal::hasContainer() || !\Drupal::getContainer()->hasParameter('install_profile')) {
    return $this;
  }
  $profile = \Drupal::installProfile();
  // If $profile is FALSE then we need to add a fake directory as a profile
  // directory in order to filter out profile provided modules. This ensures
  // that, after uninstalling a profile, a site cannot install modules
  // contained in an install profile. During installation $profile will be
  // NULL, so we need to discover all modules and profiles.
  if ($profile === FALSE) {
    // cspell:ignore CNKDSIUSYFUISEFCB
    $this->profileDirectories[] = '_does_not_exist_profile_CNKDSIUSYFUISEFCB';
  }
  elseif ($profile) {
    $this->profileDirectories[] = \Drupal::service('extension.list.profile')->getPath($profile);
  }
  return $this;
}

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