function VendorHardeningPlugin::cleanPackage

Same name in other branches
  1. 9 composer/Plugin/VendorHardening/VendorHardeningPlugin.php \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin::cleanPackage()
  2. 8.9.x composer/Plugin/VendorHardening/VendorHardeningPlugin.php \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin::cleanPackage()
  3. 11.x 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 312

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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.