Skip to content
Snippets Groups Projects
Commit 57ee1b9b authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3346659 by kunal.sachdev, phenaproxima, Wim Leers: Change...

Issue #3346659 by kunal.sachdev, phenaproxima, Wim Leers: Change 'ignore'/'ignored' to 'exclude'/'excluded' for consistent naming in public API: CollectIgnoredPathsEvent vs getExcludedPaths()
parent af056ae6
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 87 deletions
...@@ -233,11 +233,11 @@ ...@@ -233,11 +233,11 @@
* irrelevant to Composer or Package Manager. Examples include settings.php * irrelevant to Composer or Package Manager. Examples include settings.php
* and related files, public and private files, SQLite databases, and git * and related files, public and private files, SQLite databases, and git
* repositories. Custom code can subscribe to * repositories. Custom code can subscribe to
* Drupal\package_manager\Event\CollectIgnoredPathsEvent to flag paths which * Drupal\package_manager\Event\CollectPathsToExcludeEvent to flag paths which
* should never be copied into the stage directory from the active directory or * should never be copied into the stage directory from the active directory or
* vice versa. * vice versa.
* *
* @see \Drupal\package_manager\Event\CollectIgnoredPathsEvent * @see \Drupal\package_manager\Event\CollectPathsToExcludeEvent
* *
* @section sec_services Useful services * @section sec_services Useful services
* The following services are especially useful to validators: * The following services are especially useful to validators:
......
...@@ -9,15 +9,15 @@ use PhpTuf\ComposerStager\Domain\Value\PathList\PathListInterface; ...@@ -9,15 +9,15 @@ use PhpTuf\ComposerStager\Domain\Value\PathList\PathListInterface;
use PhpTuf\ComposerStager\Infrastructure\Value\PathList\PathList; use PhpTuf\ComposerStager\Infrastructure\Value\PathList\PathList;
/** /**
* Defines an event that collects ignored paths. * Defines an event that collects paths to exclude.
* *
* Ignored paths are completely ignored by Composer Stager. They are never * These paths are excluded by Composer Stager and are never copied into the
* copied into the stage directory from the active directory, or vice-versa. * stage directory from the active directory, or vice-versa.
*/ */
class CollectIgnoredPathsEvent extends StageEvent implements PathListInterface { class CollectPathsToExcludeEvent extends StageEvent implements PathListInterface {
/** /**
* The list of ignored paths. * The list of paths to exclude.
* *
* @var \PhpTuf\ComposerStager\Domain\Value\PathList\PathListInterface * @var \PhpTuf\ComposerStager\Domain\Value\PathList\PathListInterface
*/ */
......
...@@ -18,15 +18,15 @@ class PreApplyEvent extends PreOperationStageEvent { ...@@ -18,15 +18,15 @@ class PreApplyEvent extends PreOperationStageEvent {
* *
* @param \Drupal\package_manager\StageBase $stage * @param \Drupal\package_manager\StageBase $stage
* The stage which fired this event. * The stage which fired this event.
* @param string[] $ignored_paths * @param string[] $paths_to_exclude
* The list of ignored paths. These will not be copied from the stage * The list of paths to exclude. These will not be copied from the stage
* directory to the active directory, nor be deleted from the active * directory to the active directory, nor be deleted from the active
* directory if they exist, when the stage directory is copied back into * directory if they exist, when the stage directory is copied back into
* the active directory. * the active directory.
*/ */
public function __construct(StageBase $stage, array $ignored_paths) { public function __construct(StageBase $stage, array $paths_to_exclude) {
parent::__construct($stage); parent::__construct($stage);
$this->excludedPaths = $ignored_paths; $this->excludedPaths = $paths_to_exclude;
} }
} }
...@@ -18,13 +18,13 @@ class PreCreateEvent extends PreOperationStageEvent { ...@@ -18,13 +18,13 @@ class PreCreateEvent extends PreOperationStageEvent {
* *
* @param \Drupal\package_manager\StageBase $stage * @param \Drupal\package_manager\StageBase $stage
* The stage which fired this event. * The stage which fired this event.
* @param string[] $ignored_paths * @param string[] $paths_to_exclude
* The list of ignored paths. These will not be copied into the stage * The list of paths to exclude. These will not be copied into the stage
* directory when it is created. * directory when it is created.
*/ */
public function __construct(StageBase $stage, array $ignored_paths) { public function __construct(StageBase $stage, array $paths_to_exclude) {
parent::__construct($stage); parent::__construct($stage);
$this->excludedPaths = $ignored_paths; $this->excludedPaths = $paths_to_exclude;
} }
} }
...@@ -28,12 +28,12 @@ class StatusCheckEvent extends PreOperationStageEvent { ...@@ -28,12 +28,12 @@ class StatusCheckEvent extends PreOperationStageEvent {
* this event. * this event.
*/ */
public function getExcludedPaths(): ?array { public function getExcludedPaths(): ?array {
if (isset($this->excludedPaths)) { if (isset($this->pathsToExclude)) {
return array_unique($this->excludedPaths); return array_unique($this->pathsToExclude);
} }
if (empty($this->getResults(SystemManager::REQUIREMENT_ERROR))) { if (empty($this->getResults(SystemManager::REQUIREMENT_ERROR))) {
throw new \LogicException('$ignored_paths should only be NULL if the error that caused the paths to not be collected was added to the status check event.'); throw new \LogicException('$paths_to_exclude should only be NULL if the error that caused the paths to not be collected was added to the status check event.');
} }
return NULL; return NULL;
} }
...@@ -43,10 +43,10 @@ class StatusCheckEvent extends PreOperationStageEvent { ...@@ -43,10 +43,10 @@ class StatusCheckEvent extends PreOperationStageEvent {
* *
* @param \Drupal\package_manager\StageBase $stage * @param \Drupal\package_manager\StageBase $stage
* The stage which fired this event. * The stage which fired this event.
* @param string[]|null $excludedPaths * @param string[]|null $pathsToExclude
* The list of ignored paths, or NULL if they could not be collected. * The list of paths to exclude, or NULL if they could not be collected.
*/ */
public function __construct(StageBase $stage, private ?array $excludedPaths) { public function __construct(StageBase $stage, private ?array $pathsToExclude) {
parent::__construct($stage); parent::__construct($stage);
} }
......
...@@ -5,7 +5,7 @@ declare(strict_types = 1); ...@@ -5,7 +5,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\package_manager\ComposerInspector; use Drupal\package_manager\ComposerInspector;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -38,20 +38,20 @@ final class GitExcluder implements EventSubscriberInterface { ...@@ -38,20 +38,20 @@ final class GitExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeGitDirectories', CollectPathsToExcludeEvent::class => 'excludeGitDirectories',
]; ];
} }
/** /**
* Excludes .git directories from stage operations. * Excludes .git directories from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
* *
* @throws \Exception * @throws \Exception
* See \Drupal\package_manager\ComposerInspector::validate(). * See \Drupal\package_manager\ComposerInspector::validate().
*/ */
public function excludeGitDirectories(CollectIgnoredPathsEvent $event): void { public function excludeGitDirectories(CollectPathsToExcludeEvent $event): void {
$project_root = $this->pathLocator->getProjectRoot(); $project_root = $this->pathLocator->getProjectRoot();
// To determine which .git directories to exclude, the installed packages // To determine which .git directories to exclude, the installed packages
......
...@@ -4,7 +4,7 @@ declare(strict_types = 1); ...@@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -33,10 +33,10 @@ class NodeModulesExcluder implements EventSubscriberInterface { ...@@ -33,10 +33,10 @@ class NodeModulesExcluder implements EventSubscriberInterface {
/** /**
* Excludes node_modules directories from stage operations. * Excludes node_modules directories from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
*/ */
public function excludeNodeModulesFiles(CollectIgnoredPathsEvent $event): void { public function excludeNodeModulesFiles(CollectPathsToExcludeEvent $event): void {
$paths = $this->scanForDirectoriesByName('node_modules'); $paths = $this->scanForDirectoriesByName('node_modules');
$this->excludeInProjectRoot($event, $paths); $this->excludeInProjectRoot($event, $paths);
} }
...@@ -46,7 +46,7 @@ class NodeModulesExcluder implements EventSubscriberInterface { ...@@ -46,7 +46,7 @@ class NodeModulesExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeNodeModulesFiles', CollectPathsToExcludeEvent::class => 'excludeNodeModulesFiles',
]; ];
} }
......
...@@ -4,7 +4,7 @@ declare(strict_types = 1); ...@@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
/** /**
* Contains methods for excluding paths from stage operations. * Contains methods for excluding paths from stage operations.
...@@ -24,13 +24,13 @@ trait PathExclusionsTrait { ...@@ -24,13 +24,13 @@ trait PathExclusionsTrait {
* This should only be used for paths that, if they exist at all, are * This should only be used for paths that, if they exist at all, are
* *guaranteed* to exist within the web root. * *guaranteed* to exist within the web root.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent|\Drupal\package_manager\Event\StageEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent|\Drupal\package_manager\Event\StageEvent $event
* The event object. * The event object.
* @param string[] $paths * @param string[] $paths
* The paths to exclude. These should be relative to the web root, and will * The paths to exclude. These should be relative to the web root, and will
* be made relative to the project root. * be made relative to the project root.
*/ */
protected function excludeInWebRoot(CollectIgnoredPathsEvent $event, array $paths): void { protected function excludeInWebRoot(CollectPathsToExcludeEvent $event, array $paths): void {
$web_root = $this->pathLocator->getWebRoot(); $web_root = $this->pathLocator->getWebRoot();
if ($web_root) { if ($web_root) {
$web_root .= '/'; $web_root .= '/';
...@@ -45,14 +45,14 @@ trait PathExclusionsTrait { ...@@ -45,14 +45,14 @@ trait PathExclusionsTrait {
/** /**
* Flags paths to be excluded, relative to the project root. * Flags paths to be excluded, relative to the project root.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent|\Drupal\package_manager\Event\StageEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent|\Drupal\package_manager\Event\StageEvent $event
* The event object. * The event object.
* @param string[] $paths * @param string[] $paths
* The paths to exclude. Absolute paths will be made relative to the project * The paths to exclude. Absolute paths will be made relative to the project
* root; relative paths will be assumed to already be relative to the * root; relative paths will be assumed to already be relative to the
* project root, and excluded as given. * project root, and excluded as given.
*/ */
protected function excludeInProjectRoot(CollectIgnoredPathsEvent $event, array $paths): void { protected function excludeInProjectRoot(CollectPathsToExcludeEvent $event, array $paths): void {
$project_root = $this->pathLocator->getProjectRoot(); $project_root = $this->pathLocator->getProjectRoot();
foreach ($paths as $path) { foreach ($paths as $path) {
......
...@@ -4,7 +4,7 @@ declare(strict_types = 1); ...@@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -35,14 +35,14 @@ class SiteConfigurationExcluder implements EventSubscriberInterface { ...@@ -35,14 +35,14 @@ class SiteConfigurationExcluder implements EventSubscriberInterface {
/** /**
* Excludes site configuration files from stage operations. * Excludes site configuration files from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
*/ */
public function excludeSiteConfiguration(CollectIgnoredPathsEvent $event): void { public function excludeSiteConfiguration(CollectPathsToExcludeEvent $event): void {
// Site configuration files are always excluded relative to the web root. // Site configuration files are always excluded relative to the web root.
$paths = []; $paths = [];
// Ignore site-specific settings files, which are always in the web root. // Exclude site-specific settings files, which are always in the web root.
// By default, Drupal core will always try to write-protect these files. // By default, Drupal core will always try to write-protect these files.
$settings_files = [ $settings_files = [
'settings.php', 'settings.php',
...@@ -61,7 +61,7 @@ class SiteConfigurationExcluder implements EventSubscriberInterface { ...@@ -61,7 +61,7 @@ class SiteConfigurationExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeSiteConfiguration', CollectPathsToExcludeEvent::class => 'excludeSiteConfiguration',
]; ];
} }
......
...@@ -6,7 +6,7 @@ namespace Drupal\package_manager\PathExcluder; ...@@ -6,7 +6,7 @@ namespace Drupal\package_manager\PathExcluder;
use Drupal\Core\StreamWrapper\LocalStream; use Drupal\Core\StreamWrapper\LocalStream;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
...@@ -42,18 +42,18 @@ final class SiteFilesExcluder implements EventSubscriberInterface { ...@@ -42,18 +42,18 @@ final class SiteFilesExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeSiteFiles', CollectPathsToExcludeEvent::class => 'excludeSiteFiles',
]; ];
} }
/** /**
* Excludes public and private files from stage operations. * Excludes public and private files from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
*/ */
public function excludeSiteFiles(CollectIgnoredPathsEvent $event): void { public function excludeSiteFiles(CollectPathsToExcludeEvent $event): void {
// Ignore public and private files. These paths could be either absolute or // Exclude public and private files. These paths could be either absolute or
// relative, depending on site settings. If they are absolute, treat them // relative, depending on site settings. If they are absolute, treat them
// as relative to the project root. Otherwise, treat them as relative to // as relative to the project root. Otherwise, treat them as relative to
// the web root. // the web root.
......
...@@ -5,7 +5,7 @@ declare(strict_types = 1); ...@@ -5,7 +5,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -38,19 +38,19 @@ class SqliteDatabaseExcluder implements EventSubscriberInterface { ...@@ -38,19 +38,19 @@ class SqliteDatabaseExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeDatabaseFiles', CollectPathsToExcludeEvent::class => 'excludeDatabaseFiles',
]; ];
} }
/** /**
* Excludes SQLite database files from stage operations. * Excludes SQLite database files from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
*/ */
public function excludeDatabaseFiles(CollectIgnoredPathsEvent $event): void { public function excludeDatabaseFiles(CollectPathsToExcludeEvent $event): void {
// If the database is SQLite, it might be located in the active directory // If the database is SQLite, it might be located in the active directory
// and we should ignore it. Always treat it as relative to the project root. // and we should exclude it. Always treat it as relative to the project root.
if ($this->database->driver() === 'sqlite') { if ($this->database->driver() === 'sqlite') {
$options = $this->database->getConnectionOptions(); $options = $this->database->getConnectionOptions();
// Nothing to exclude if the database lives outside the project root. // Nothing to exclude if the database lives outside the project root.
......
...@@ -4,7 +4,7 @@ declare(strict_types = 1); ...@@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -35,18 +35,18 @@ final class TestSiteExcluder implements EventSubscriberInterface { ...@@ -35,18 +35,18 @@ final class TestSiteExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeTestSites', CollectPathsToExcludeEvent::class => 'excludeTestSites',
]; ];
} }
/** /**
* Excludes sites/simpletest from stage operations. * Excludes sites/simpletest from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
*/ */
public function excludeTestSites(CollectIgnoredPathsEvent $event): void { public function excludeTestSites(CollectPathsToExcludeEvent $event): void {
// Always ignore automated test directories. If they exist, they will be in // Always exclude automated test directories. If they exist, they will be in
// the web root. // the web root.
$this->excludeInWebRoot($event, ['sites/simpletest']); $this->excludeInWebRoot($event, ['sites/simpletest']);
} }
......
...@@ -6,7 +6,7 @@ namespace Drupal\package_manager\PathExcluder; ...@@ -6,7 +6,7 @@ namespace Drupal\package_manager\PathExcluder;
use Drupal\Component\Serialization\Json; use Drupal\Component\Serialization\Json;
use Drupal\package_manager\ComposerInspector; use Drupal\package_manager\ComposerInspector;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -49,20 +49,20 @@ final class UnknownPathExcluder implements EventSubscriberInterface { ...@@ -49,20 +49,20 @@ final class UnknownPathExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeUnknownPaths', CollectPathsToExcludeEvent::class => 'excludeUnknownPaths',
]; ];
} }
/** /**
* Excludes unknown paths from stage operations. * Excludes unknown paths from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
* *
* @throws \Exception * @throws \Exception
* See \Drupal\package_manager\ComposerInspector::validate(). * See \Drupal\package_manager\ComposerInspector::validate().
*/ */
public function excludeUnknownPaths(CollectIgnoredPathsEvent $event): void { public function excludeUnknownPaths(CollectPathsToExcludeEvent $event): void {
$project_root = $this->pathLocator->getProjectRoot(); $project_root = $this->pathLocator->getProjectRoot();
$web_root = $project_root . DIRECTORY_SEPARATOR . $this->pathLocator->getWebRoot(); $web_root = $project_root . DIRECTORY_SEPARATOR . $this->pathLocator->getWebRoot();
if (realpath($web_root) === $project_root) { if (realpath($web_root) === $project_root) {
......
...@@ -4,7 +4,7 @@ declare(strict_types = 1); ...@@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\PathExcluder; namespace Drupal\package_manager\PathExcluder;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\PathLocator; use Drupal\package_manager\PathLocator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -35,20 +35,20 @@ final class VendorHardeningExcluder implements EventSubscriberInterface { ...@@ -35,20 +35,20 @@ final class VendorHardeningExcluder implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents(): array { public static function getSubscribedEvents(): array {
return [ return [
CollectIgnoredPathsEvent::class => 'excludeVendorHardeningFiles', CollectPathsToExcludeEvent::class => 'excludeVendorHardeningFiles',
]; ];
} }
/** /**
* Excludes vendor hardening files from stage operations. * Excludes vendor hardening files from stage operations.
* *
* @param \Drupal\package_manager\Event\CollectIgnoredPathsEvent $event * @param \Drupal\package_manager\Event\CollectPathsToExcludeEvent $event
* The event object. * The event object.
*/ */
public function excludeVendorHardeningFiles(CollectIgnoredPathsEvent $event): void { public function excludeVendorHardeningFiles(CollectPathsToExcludeEvent $event): void {
// 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 excluded.
$vendor_dir = $this->pathLocator->getVendorDirectory(); $vendor_dir = $this->pathLocator->getVendorDirectory();
$this->excludeInProjectRoot($event, [ $this->excludeInProjectRoot($event, [
$vendor_dir . '/web.config', $vendor_dir . '/web.config',
......
...@@ -13,7 +13,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait; ...@@ -13,7 +13,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TempStore\SharedTempStore; use Drupal\Core\TempStore\SharedTempStore;
use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\Core\TempStore\SharedTempStoreFactory;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\Event\PostApplyEvent; use Drupal\package_manager\Event\PostApplyEvent;
use Drupal\package_manager\Event\PostCreateEvent; use Drupal\package_manager\Event\PostCreateEvent;
use Drupal\package_manager\Event\PostDestroyEvent; use Drupal\package_manager\Event\PostDestroyEvent;
...@@ -250,20 +250,20 @@ abstract class StageBase implements LoggerAwareInterface { ...@@ -250,20 +250,20 @@ abstract class StageBase implements LoggerAwareInterface {
} }
/** /**
* Collects paths that Composer Stager should ignore. * Collects paths that Composer Stager should exclude.
* *
* @return string[] * @return string[]
* A list of paths that Composer Stager should ignore when creating the * A list of paths that Composer Stager should exclude when creating the
* stage directory and applying staged changes to the active directory. * stage directory and applying staged changes to the active directory.
* *
* @throws \Drupal\package_manager\Exception\StageException * @throws \Drupal\package_manager\Exception\StageException
* Thrown if an exception occurs while collecting ignored paths. * Thrown if an exception occurs while collecting paths to exclude.
* *
* @see ::create() * @see ::create()
* @see ::apply() * @see ::apply()
*/ */
protected function getIgnoredPaths(): array { protected function getPathsToExclude(): array {
$event = new CollectIgnoredPathsEvent($this); $event = new CollectPathsToExcludeEvent($this);
try { try {
$this->eventDispatcher->dispatch($event); $this->eventDispatcher->dispatch($event);
} }
...@@ -322,7 +322,7 @@ abstract class StageBase implements LoggerAwareInterface { ...@@ -322,7 +322,7 @@ abstract class StageBase implements LoggerAwareInterface {
$active_dir = $this->pathFactory->create($this->pathLocator->getProjectRoot()); $active_dir = $this->pathFactory->create($this->pathLocator->getProjectRoot());
$stage_dir = $this->pathFactory->create($this->getStageDirectory()); $stage_dir = $this->pathFactory->create($this->getStageDirectory());
$event = new PreCreateEvent($this, $this->getIgnoredPaths()); $event = new PreCreateEvent($this, $this->getPathsToExclude());
// If an error occurs and we won't be able to create the stage, mark it as // If an error occurs and we won't be able to create the stage, mark it as
// available. // available.
$this->dispatch($event, [$this, 'markAsAvailable']); $this->dispatch($event, [$this, 'markAsAvailable']);
...@@ -443,20 +443,20 @@ abstract class StageBase implements LoggerAwareInterface { ...@@ -443,20 +443,20 @@ abstract class StageBase implements LoggerAwareInterface {
// If an error occurs while dispatching the events, ensure that ::destroy() // If an error occurs while dispatching the events, ensure that ::destroy()
// doesn't think we're in the middle of applying the staged changes to the // doesn't think we're in the middle of applying the staged changes to the
// active directory. // active directory.
$event = new PreApplyEvent($this, $this->getIgnoredPaths()); $event = new PreApplyEvent($this, $this->getPathsToExclude());
$this->tempStore->set(self::TEMPSTORE_APPLY_TIME_KEY, $this->time->getRequestTime()); $this->tempStore->set(self::TEMPSTORE_APPLY_TIME_KEY, $this->time->getRequestTime());
$this->dispatch($event, $this->setNotApplying()); $this->dispatch($event, $this->setNotApplying());
// Create a marker file so that we can tell later on if the commit failed. // Create a marker file so that we can tell later on if the commit failed.
$this->failureMarker->write($this, $this->getFailureMarkerMessage()); $this->failureMarker->write($this, $this->getFailureMarkerMessage());
// Exclude the failure file from the commit operation. // Exclude the failure file from the commit operation.
$ignored_paths = new PathList($event->getExcludedPaths()); $paths_to_exclude = new PathList($event->getExcludedPaths());
$ignored_paths->add([ $paths_to_exclude->add([
$this->failureMarker->getPath(), $this->failureMarker->getPath(),
]); ]);
try { try {
$this->committer->commit($stage_dir, $active_dir, $ignored_paths, NULL, $timeout); $this->committer->commit($stage_dir, $active_dir, $paths_to_exclude, NULL, $timeout);
} }
catch (InvalidArgumentException | PreconditionException $e) { catch (InvalidArgumentException | PreconditionException $e) {
// The commit operation has not started yet, so we can clear the failure // The commit operation has not started yet, so we can clear the failure
......
...@@ -4,7 +4,7 @@ declare(strict_types = 1); ...@@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager; namespace Drupal\package_manager;
use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\CollectPathsToExcludeEvent;
use Drupal\package_manager\Event\StatusCheckEvent; use Drupal\package_manager\Event\StatusCheckEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
...@@ -33,20 +33,20 @@ trait StatusCheckTrait { ...@@ -33,20 +33,20 @@ trait StatusCheckTrait {
protected function runStatusCheck(StageBase $stage, EventDispatcherInterface $event_dispatcher = NULL): array { protected function runStatusCheck(StageBase $stage, EventDispatcherInterface $event_dispatcher = NULL): array {
$event_dispatcher ??= \Drupal::service('event_dispatcher'); $event_dispatcher ??= \Drupal::service('event_dispatcher');
try { try {
$ignored_paths_event = new CollectIgnoredPathsEvent($stage); $paths_to_exclude_event = new CollectPathsToExcludeEvent($stage);
$event_dispatcher->dispatch($ignored_paths_event); $event_dispatcher->dispatch($paths_to_exclude_event);
$event = new StatusCheckEvent($stage, $ignored_paths_event->getAll()); $event = new StatusCheckEvent($stage, $paths_to_exclude_event->getAll());
} }
catch (\Throwable $throwable) { catch (\Throwable $throwable) {
// We can dispatch the status check event without the ignored paths, but // We can dispatch the status check event without the paths to exclude,
// it must be set explicitly to NULL, to allow those status checks to run // but it must be set explicitly to NULL, to allow those status checks to
// that do not need the ignored paths. // run that do not need the paths to exclude.
$event = new StatusCheckEvent($stage, NULL); $event = new StatusCheckEvent($stage, NULL);
// Add the error that was encountered so that regardless of any other // Add the error that was encountered so that regardless of any other
// validation errors BaseRequirementsFulfilledValidator will stop the // validation errors BaseRequirementsFulfilledValidator will stop the
// event propagation after the base requirement validators have run. // event propagation after the base requirement validators have run.
// @see \Drupal\package_manager\Validator\BaseRequirementsFulfilledValidator // @see \Drupal\package_manager\Validator\BaseRequirementsFulfilledValidator
$event->addErrorFromThrowable($throwable, t('Unable to collect the ignored paths.')); $event->addErrorFromThrowable($throwable, t('Unable to collect the paths to exclude.'));
} }
$event_dispatcher->dispatch($event); $event_dispatcher->dispatch($event);
......
...@@ -61,17 +61,17 @@ class SymlinkValidator implements EventSubscriberInterface { ...@@ -61,17 +61,17 @@ class SymlinkValidator implements EventSubscriberInterface {
} }
$stage_dir = $this->pathFactory->create($stage_dir); $stage_dir = $this->pathFactory->create($stage_dir);
$ignored_paths = $event->getExcludedPaths(); $excluded_paths = $event->getExcludedPaths();
// Return early if no ignored paths were collected because this validator // Return early if no excluded paths were collected because this validator
// is dependent on knowing which paths to ignore when searching for // is dependent on knowing which paths to exclude when searching for
// symlinks. // symlinks.
// @see \Drupal\package_manager\StatusCheckTrait::runStatusCheck() // @see \Drupal\package_manager\StatusCheckTrait::runStatusCheck()
if ($ignored_paths === NULL) { if ($excluded_paths === NULL) {
return; return;
} }
try { try {
$this->precondition->assertIsFulfilled($active_dir, $stage_dir, new PathList($ignored_paths)); $this->precondition->assertIsFulfilled($active_dir, $stage_dir, new PathList($excluded_paths));
} }
catch (PreconditionException $e) { catch (PreconditionException $e) {
$event->addErrorFromThrowable($e); $event->addErrorFromThrowable($e);
......
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