function Dependency::createFromString
Creates a new instance of this class from a dependency string.
Parameters
string $dependency: A dependency string, which specifies a module or theme dependency, and optionally the project it comes from and a constraint string that determines the versions that are supported. Supported formats include:
- 'module'
- 'project:module'
- 'project:module (>=version, <=version)'.
Return value
static
2 calls to Dependency::createFromString()
- DatabaseDriver::getAutoloadInfo in core/
lib/ Drupal/ Core/ Extension/ DatabaseDriver.php - ModuleHandler::buildModuleDependencies in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Determines which modules require and are required by each module.
File
-
core/
lib/ Drupal/ Core/ Extension/ Dependency.php, line 125
Class
- Dependency
- A value object representing dependency information.
Namespace
Drupal\Core\ExtensionCode
public static function createFromString($dependency) {
if (str_contains($dependency, ':')) {
[
$project,
$dependency,
] = explode(':', $dependency);
}
else {
$project = '';
}
$parts = explode('(', $dependency, 2);
$name = trim($parts[0]);
$version_string = isset($parts[1]) ? rtrim($parts[1], ") ") : '';
return new static($name, $project, $version_string);
}