function ExtensionPathResolver::getPathname

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/ExtensionPathResolver.php \Drupal\Core\Extension\ExtensionPathResolver::getPathname()
  2. 11.x core/lib/Drupal/Core/Extension/ExtensionPathResolver.php \Drupal\Core\Extension\ExtensionPathResolver::getPathname()

Gets the info file path for the extension.

Parameters

string $type: The extension type.

string $name: The extension name.

Return value

string|null The extension path, or NULL if unknown.

1 call to ExtensionPathResolver::getPathname()
ExtensionPathResolver::getPath in core/lib/Drupal/Core/Extension/ExtensionPathResolver.php
Gets the extension directory path.

File

core/lib/Drupal/Core/Extension/ExtensionPathResolver.php, line 50

Class

ExtensionPathResolver
Factory for getting extension lists by type.

Namespace

Drupal\Core\Extension

Code

public function getPathname(string $type, string $name) : ?string {
    if ($type === 'core') {
        return 'core/core.info.yml';
    }
    if (!isset($this->extensionLists[$type])) {
        throw new UnknownExtensionTypeException(sprintf('Extension type %s is unknown.', $type));
    }
    try {
        return $this->extensionLists[$type]
            ->getPathname($name);
    } catch (UnknownExtensionException $e) {
        // Catch the exception. This will result in triggering an error.
        // If the filename is still unknown, create a user-level error message.
        trigger_error(sprintf('The following %s is missing from the file system: %s', $type, $name), E_USER_WARNING);
        return NULL;
    }
}

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