function RequireEventTrait::getKeyedPackages
Gets packages as a keyed array.
Parameters
string[] $packages: The packages, in the form 'vendor/name:version'.
Return value
string[] An array of packages where the values are version constraints and keys are package names in the form `vendor/name`. Packages without a version constraint will default to `*`.
2 calls to RequireEventTrait::getKeyedPackages()
- RequireEventTrait::getDevPackages in core/
modules/ package_manager/ src/ Event/ RequireEventTrait.php - Gets the dev packages.
- RequireEventTrait::getRuntimePackages in core/
modules/ package_manager/ src/ Event/ RequireEventTrait.php - Gets the runtime (i.e., non-dev) packages.
File
-
core/
modules/ package_manager/ src/ Event/ RequireEventTrait.php, line 85
Class
- RequireEventTrait
- Common methods for pre- and post-require events.
Namespace
Drupal\package_manager\EventCode
private function getKeyedPackages(array $packages) : array {
$keyed_packages = [];
foreach ($packages as $package) {
if (strpos($package, ':') > 0) {
[
$name,
$constraint,
] = explode(':', $package);
}
else {
[
$name,
$constraint,
] = [
$package,
'*',
];
}
$keyed_packages[$name] = $constraint;
}
return $keyed_packages;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.