public static function Dependency::createFromString in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Extension/Dependency.php \Drupal\Core\Extension\Dependency::createFromString()
- 9 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
4 calls to Dependency::createFromString()
- DependencyTest::testCreateFromString in core/
tests/ Drupal/ Tests/ Core/ Extension/ DependencyTest.php - @covers ::createFromString @dataProvider providerCreateFromString
- install_profile_info in core/
includes/ install.inc - Retrieves information about an installation profile from its .info.yml file.
- ModuleExtensionList::ensureRequiredDependencies in core/
lib/ Drupal/ Core/ Extension/ ModuleExtensionList.php - Marks dependencies of required modules as 'required', recursively.
- 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 (strpos($dependency, ':') !== FALSE) {
[
$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);
}