function VendorHardeningPlugin::cleanPackage

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

string $vendor_dir: Path to vendor directory

string $package_name: Name of 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 301

Class

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

Namespace

Drupal\Composer\Plugin\VendorHardening

Code

public function cleanPackage($vendor_dir, $package_name) {
    // Normalize package names to lower case.
    $package_name = strtolower($package_name);
    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($vendor_dir, $package_name, $paths_for_package);
    }
}

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