Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. VendorHardeningPlugin.php

function 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\VendorHardening

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal