function ModuleHandler::parseDependency
Parses a dependency for comparison by drupal_check_incompatibility().
Parameters
string $dependency: A dependency string, which specifies a module dependency, and optionally the project it comes from and versions that are supported. Supported formats include:
- 'module'
- 'project:module'
- 'project:module (>=version, version)'.
Return value
array An associative array with three keys:
- 'name' includes the name of the thing to depend on (e.g. 'foo').
- 'original_version' contains the original version string (which can be used in the UI for reporting incompatibilities).
- 'versions' is a list of associative arrays, each containing the keys 'op' and 'version'. 'op' can be one of: '=', '==', '!=', '<>', '<', '<=', '>', or '>='. 'version' is one piece like '4.5-beta3'.
Callers should pass this structure to drupal_check_incompatibility().
Deprecated
in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\Dependency::createFromString() instead.
See also
https://www.drupal.org/node/2756875
1 call to ModuleHandler::parseDependency()
- DeprecatedModuleHandlerTest::testDependencyParsing in core/
tests/ Drupal/ Tests/ Core/ Extension/ DeprecatedModuleHandlerTest.php - @dataProvider dependencyProvider @covers ::parseDependency @expectedDeprecation Drupal\Core\Extension\ModuleHandler::parseDependency is deprecated. Use \Drupal\Core\Extension\Dependency::createFromString() instead. Seeā¦
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 723
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
public static function parseDependency($dependency) {
@trigger_error(__METHOD__ . ' is deprecated. Use \\Drupal\\Core\\Extension\\Dependency::createFromString() instead. See https://www.drupal.org/node/2756875', E_USER_DEPRECATED);
$dependency = Dependency::createFromString($dependency);
$result = [
'name' => $dependency->getName(),
'project' => $dependency->getProject(),
'original_version' => $dependency['original_version'],
'versions' => $dependency['versions'],
];
return array_filter($result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.