You are here

public function ExtensionPathResolver::getPathname in Drupal 9

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;
  }
}