You are here

public function AllowedPackages::event in Drupal 8

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

Handles package events during a 'composer require' operation.

Parameters

\Composer\Installer\PackageEvent $event: Composer package event sent on install/update/remove.

Overrides PostPackageEventListenerInterface::event

File

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

Class

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

Namespace

Drupal\Composer\Plugin\Scaffold

Code

public function event(PackageEvent $event) {
  $operation = $event
    ->getOperation();

  // Determine the package. Later, in evaluateNewPackages(), we will report
  // which of the newly-installed packages have scaffold operations, and
  // whether or not they are allowed to scaffold by the allowed-packages
  // option in the root-level composer.json file.
  $operationType = $this
    ->getOperationType($operation);
  $package = $operationType === 'update' ? $operation
    ->getTargetPackage() : $operation
    ->getPackage();
  if (ScaffoldOptions::hasOptions($package
    ->getExtra())) {
    $this->newPackages[$package
      ->getName()] = $package;
  }
}