Newer
Older

Adam G-H
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Drupal\package_manager\PathExcluder;
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']);
}
}