class VendorHardeningExcluder

Excludes vendor hardening files from stage operations.

@internal This is an internal part of Package Manager and may be changed or removed at any time without warning. External code should not interact with this class.

Hierarchy

  • class \Drupal\package_manager\PathExcluder\VendorHardeningExcluder extends \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of VendorHardeningExcluder

File

core/modules/package_manager/src/PathExcluder/VendorHardeningExcluder.php, line 19

Namespace

Drupal\package_manager\PathExcluder
View source
final class VendorHardeningExcluder implements EventSubscriberInterface {
  public function __construct(private readonly PathLocator $pathLocator) {
  }
  
  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() : array {
    return [
      CollectPathsToExcludeEvent::class => 'excludeVendorHardeningFiles',
    ];
  }
  
  /**
   * Excludes vendor hardening files from stage operations.
   *
   * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
   *   The event object.
   */
  public function excludeVendorHardeningFiles(CollectPathsToExcludeEvent $event) : void {
    // If the core-vendor-hardening plugin (used in the legacy-project template)
    // is present, it may have written security hardening files in the vendor
    // directory. They should always be excluded.
    $vendor_dir = $this->pathLocator
      ->getVendorDirectory();
    $event->addPathsRelativeToProjectRoot([
      $vendor_dir . '/.htaccess',
    ]);
  }

}

Members

Title Sort descending Modifiers Object type Summary
VendorHardeningExcluder::excludeVendorHardeningFiles public function Excludes vendor hardening files from stage operations.
VendorHardeningExcluder::getSubscribedEvents public static function
VendorHardeningExcluder::__construct public function

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