function Dependency::createFromString
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/Dependency.php \Drupal\Core\Extension\Dependency::createFromString()
- 8.9.x core/lib/Drupal/Core/Extension/Dependency.php \Drupal\Core\Extension\Dependency::createFromString()
- 11.x core/lib/Drupal/Core/Extension/Dependency.php \Drupal\Core\Extension\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
3 calls to Dependency::createFromString()
- DatabaseDriver::getAutoloadInfo in core/
lib/ Drupal/ Core/ Extension/ DatabaseDriver.php - DependencyTest::testCreateFromString in core/
tests/ Drupal/ Tests/ Core/ Extension/ DependencyTest.php - @covers ::createFromString @dataProvider providerCreateFromString
- ModuleHandler::buildModuleDependencies in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.