You are here

public function AllowedPackages::event in Drupal 10

Same name and namespace in other branches
  1. 8 composer/Plugin/Scaffold/AllowedPackages.php \Drupal\Composer\Plugin\Scaffold\AllowedPackages::event()
  2. 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 97

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.
  $package = $operation
    ->getOperationType() === 'update' ? $operation
    ->getTargetPackage() : $operation
    ->getPackage();
  if (ScaffoldOptions::hasOptions($package
    ->getExtra())) {
    $this->newPackages[$package
      ->getName()] = $package;
  }
}