You are here

protected function AllowedPackages::evaluateNewPackages in Drupal 8

Same name and namespace in other branches
  1. 9 composer/Plugin/Scaffold/AllowedPackages.php \Drupal\Composer\Plugin\Scaffold\AllowedPackages::evaluateNewPackages()

Evaluates newly-added packages and see if they are already allowed.

For now we will only emit warnings if they are not.

Parameters

array $allowed_packages: Mapping of package names to PackageInterface of packages already accumulated.

Return value

\Composer\Package\PackageInterface[] Mapping of package names to PackageInterface in priority order.

1 call to AllowedPackages::evaluateNewPackages()
AllowedPackages::getAllowedPackages in composer/Plugin/Scaffold/AllowedPackages.php
Gets a list of all packages that are allowed to copy scaffold files.

File

composer/Plugin/Scaffold/AllowedPackages.php, line 167

Class

AllowedPackages
Determine recursively which packages have been allowed to scaffold files.

Namespace

Drupal\Composer\Plugin\Scaffold

Code

protected function evaluateNewPackages(array $allowed_packages) {
  foreach ($this->newPackages as $name => $newPackage) {
    if (!array_key_exists($name, $allowed_packages)) {
      $this->io
        ->write("Not scaffolding files for <comment>{$name}</comment>, because it is not listed in the element 'extra.drupal-scaffold.allowed-packages' in the root-level composer.json file.");
    }
    else {
      $this->io
        ->write("Package <comment>{$name}</comment> has scaffold operations, and is already allowed in the root-level composer.json file.");
    }
  }

  // @todo We could prompt the user and ask if they wish to allow a
  // newly-added package. This might be useful if, for example, the user
  // might wish to require an installation profile that contains scaffolded
  // assets. For more information, see:
  // https://www.drupal.org/project/drupal/issues/3064990
  return $allowed_packages;
}