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
3 calls to Dependency::createFromString()
- DatabaseDriver::getAutoloadInfo in core/lib/ Drupal/ Core/ Extension/ DatabaseDriver.php 
- Returns an array with the driver's autoload information.
- DependencyTest::testCreateFromString in core/tests/ Drupal/ Tests/ Core/ Extension/ DependencyTest.php 
- Tests create from string.
- 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);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
