Skip to content
Snippets Groups Projects
Commit 116104c9 authored by Adam G-H's avatar Adam G-H
Browse files

Split test site exclusions into own class

parent c71efcf7
No related branches found
No related tags found
1 merge request!263Issue #3274323: Split ExcludedPathsSubscriber into multiple classes
This commit is part of merge request !263. Comments created here will be created in the context of that merge request.
...@@ -128,6 +128,12 @@ services: ...@@ -128,6 +128,12 @@ services:
- '@string_translation' - '@string_translation'
tags: tags:
- { name: event_subscriber } - { name: event_subscriber }
package_manager.test_site_excluder:
class: Drupal\package_manager\EventSubscriber\TestSiteExcluder
arguments:
- '@package_manager.path_locator'
tags:
- { name: event_subscriber }
package_manager.excluded_paths_subscriber: package_manager.excluded_paths_subscriber:
class: Drupal\package_manager\EventSubscriber\ExcludedPathsSubscriber class: Drupal\package_manager\EventSubscriber\ExcludedPathsSubscriber
arguments: arguments:
......
...@@ -83,10 +83,6 @@ class ExcludedPathsSubscriber implements EventSubscriberInterface { ...@@ -83,10 +83,6 @@ class ExcludedPathsSubscriber implements EventSubscriberInterface {
// project root, and paths that are relative to the web root. // project root, and paths that are relative to the web root.
$web = $project = []; $web = $project = [];
// Always ignore automated test directories. If they exist, they will be in
// the web root.
$web[] = 'sites/simpletest';
// If the core-vendor-hardening plugin (used in the legacy-project template) // If the core-vendor-hardening plugin (used in the legacy-project template)
// is present, it may have written security hardening files in the vendor // is present, it may have written security hardening files in the vendor
// directory. They should always be ignored. // directory. They should always be ignored.
......
<?php
namespace Drupal\package_manager\EventSubscriber;
use Drupal\package_manager\Event\PreApplyEvent;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Event\StageEvent;
use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Excludes 'sites/simpletest' from staging operations.
*/
class TestSiteExcluder implements EventSubscriberInterface {
use PathExclusionsTrait;
/**
* Constructs a TestSiteExcluder object.
*
* @param \Drupal\package_manager\PathLocator $path_locator
* The path locator service.
*/
public function __construct(PathLocator $path_locator) {
$this->pathLocator = $path_locator;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
PreCreateEvent::class => 'excludeTestSites',
PreApplyEvent::class => 'excludeTestSites',
];
}
/**
* Excludes sites/simpletest from staging operations.
*
* @param \Drupal\package_manager\Event\StageEvent $event
* The event object.
*/
public function excludeTestSites(StageEvent $event): void {
// Always ignore automated test directories. If they exist, they will be in
// the web root.
$this->excludeInWebRoot($event, ['sites/simpletest']);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment