function ExtensionList::getPathname
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/ExtensionList.php \Drupal\Core\Extension\ExtensionList::getPathname()
- 8.9.x core/lib/Drupal/Core/Extension/ExtensionList.php \Drupal\Core\Extension\ExtensionList::getPathname()
- 10 core/lib/Drupal/Core/Extension/ExtensionList.php \Drupal\Core\Extension\ExtensionList::getPathname()
Gets the info file path for an extension.
The info path, whether provided, cached, or retrieved from the database, is only returned if the file exists.
This function plays a key role in allowing Drupal's extensions (modules, themes, profiles, theme_engines, etc.) to be located in different places depending on a site's configuration. For example, a module 'foo' may legally be located in any of these four places:
- core/modules/foo/foo.info.yml
- modules/foo/foo.info.yml
- sites/all/modules/foo/foo.info.yml
- sites/example.com/modules/foo/foo.info.yml
while a theme 'bar' may be located in any of the following four places:
- core/themes/bar/bar.info.yml
- themes/bar/bar.info.yml
- sites/all/themes/bar/bar.info.yml
- sites/example.com/themes/bar/bar.info.yml
An installation profile maybe be located in any of the following places:
- core/profiles/baz/baz.info.yml
- profiles/baz/baz.info.yml
Calling ExtensionList::getPathname('foo') will give you one of the above, depending on where the extension is located and what type it is.
Parameters
string $extension_name: The machine name of the extension for which the pathname is requested.
Return value
string The drupal-root relative filename and path of the requested extension's .info.yml file.
Throws
\Drupal\Core\Extension\Exception\UnknownExtensionException If there is no extension with the supplied machine name.
1 call to ExtensionList::getPathname()
- ExtensionList::getPath in core/
lib/ Drupal/ Core/ Extension/ ExtensionList.php - Gets the path to an extension of a specific type (module, theme, etc.).
1 method overrides ExtensionList::getPathname()
- DatabaseDriverList::getPathname in core/
lib/ Drupal/ Core/ Extension/ DatabaseDriverList.php
File
-
core/
lib/ Drupal/ Core/ Extension/ ExtensionList.php, line 509
Class
- ExtensionList
- Provides available extensions.
Namespace
Drupal\Core\ExtensionCode
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 (($path_names = $this->getPathNames()) && isset($path_names[$extension_name])) {
return $path_names[$extension_name];
}
throw new UnknownExtensionException("The {$this->type} {$extension_name} does not exist.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.