You are here

public function VendorHardeningPlugin::cleanPackage in Drupal 9

Same name and namespace in other branches
  1. 8 composer/Plugin/VendorHardening/VendorHardeningPlugin.php \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin::cleanPackage()

Clean a single package.

This applies in the context of a package post-install or post-update event.

Parameters

\Composer\Package\PackageInterface $package: The package to clean.

2 calls to VendorHardeningPlugin::cleanPackage()
VendorHardeningPlugin::onPostPackageInstall in composer/Plugin/VendorHardening/VendorHardeningPlugin.php
POST_PACKAGE_INSTALL event handler.
VendorHardeningPlugin::onPostPackageUpdate in composer/Plugin/VendorHardening/VendorHardeningPlugin.php
POST_PACKAGE_UPDATE event handler.

File

composer/Plugin/VendorHardening/VendorHardeningPlugin.php, line 307

Class

VendorHardeningPlugin
A Composer plugin to clean out your project's vendor directory.

Namespace

Drupal\Composer\Plugin\VendorHardening

Code

public function cleanPackage(PackageInterface $package) {

  // Normalize package names to lower case.
  $package_name = strtolower($package
    ->getName());
  if (isset($this->packagesAlreadyCleaned[$package_name])) {
    $this->io
      ->writeError(sprintf('%s<info>%s</info> already cleaned.', str_repeat(' ', 4), $package_name), TRUE, IOInterface::VERY_VERBOSE);
    return;
  }
  $paths_for_package = $this->config
    ->getPathsForPackage($package_name);
  if ($paths_for_package) {
    $this->io
      ->writeError(sprintf('%sCleaning: <info>%s</info>', str_repeat(' ', 4), $package_name));
    $this
      ->cleanPathsForPackage($package, $paths_for_package);
  }
}