You are here

public function ExtensionListTrait::getPathname in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Installer/ExtensionListTrait.php \Drupal\Core\Installer\ExtensionListTrait::getPathname()

See also

\Drupal\Core\Extension\ExtensionList::getPathname()

File

core/lib/Drupal/Core/Installer/ExtensionListTrait.php, line 36

Class

ExtensionListTrait
Provides common functionality for the extension list classes.

Namespace

Drupal\Core\Installer

Code

public function getPathname($extension_name) {
  if (isset($this->addedPathNames[$extension_name])) {
    return $this->addedPathNames[$extension_name];
  }
  elseif (isset($this->pathNames[$extension_name])) {
    return $this->pathNames[$extension_name];
  }
  elseif (isset(static::$staticAddedPathNames[$extension_name])) {
    return static::$staticAddedPathNames[$extension_name];
  }
  elseif (($path_names = $this
    ->getPathnames()) && isset($path_names[$extension_name])) {

    // Ensure we don't have to do path scanning more than really needed.
    foreach ($path_names as $extension => $path_name) {
      static::$staticAddedPathNames[$extension] = $path_name;
    }
    return $path_names[$extension_name];
  }
  throw new \InvalidArgumentException("The {$this->type} {$extension_name} does not exist.");
}