function VendorHardeningPlugin::removeBinBeforeCleanup
Same name in other branches
- 9 composer/Plugin/VendorHardening/VendorHardeningPlugin.php \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin::removeBinBeforeCleanup()
- 8.9.x composer/Plugin/VendorHardening/VendorHardeningPlugin.php \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin::removeBinBeforeCleanup()
- 10 composer/Plugin/VendorHardening/VendorHardeningPlugin.php \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin::removeBinBeforeCleanup()
Remove bin config for packages that would have the bin file removed.
Where the configured bin files are in the directories to be removed, remove the bin config.
Parameters
\Composer\Package\BasePackage $package: The package we're cleaning up.
2 calls to VendorHardeningPlugin::removeBinBeforeCleanup()
- VendorHardeningPlugin::onPrePackageInstall in composer/
Plugin/ VendorHardening/ VendorHardeningPlugin.php - PRE_PACKAGE_INSTALL event handler.
- VendorHardeningPlugin::onPrePackageUpdate in composer/
Plugin/ VendorHardening/ VendorHardeningPlugin.php - PRE_PACKAGE_UPDATE event handler.
File
-
composer/
Plugin/ VendorHardening/ VendorHardeningPlugin.php, line 171
Class
- VendorHardeningPlugin
- A Composer plugin to clean out your project's vendor directory.
Namespace
Drupal\Composer\Plugin\VendorHardeningCode
protected function removeBinBeforeCleanup(BasePackage $package) : void {
// We can process AliasPackage and Package objects, and they share the
// BasePackage parent class. However, since there is no common interface for
// these package types that allow for the setBinaries() method, and since
// BasePackage does not include the setBinaries() method, we have to make
// sure we're processing a class with a setBinaries() method.
if (!method_exists($package, 'setBinaries')) {
return;
}
$binaries = $package->getBinaries();
$clean_paths = $this->config
->getPathsForPackage($package->getName());
// Only do this if there are binaries and cleanup paths.
if (!$binaries || !$clean_paths) {
return;
}
if ($unset_these_binaries = $this->findBinOverlap($binaries, $clean_paths)) {
$this->io
->writeError(sprintf('%sModifying bin config for <info>%s</info> which overlaps with cleanup directories.', str_repeat(' ', 4), $package->getName()), TRUE, IOInterface::VERBOSE);
$modified_binaries = [];
foreach ($binaries as $binary) {
if (!in_array($binary, $unset_these_binaries)) {
$modified_binaries[] = $binary;
}
}
$package->setBinaries($modified_binaries);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.