function ExtensionPathResolver::getPathname

Same name in other branches
  1. 10 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 49

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])) {
        @trigger_error('Calling getPathname() with an invalid $type parameter is deprecated in drupal:9.3.0 and will throw an \\Drupal\\Core\\Extension\\Exception\\UnknownExtensionTypeException in drupal:10.0.0. See https://www.drupal.org/node/2940438', E_USER_DEPRECATED);
        return NULL;
    }
    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.