public function ExcludedPathsSubscriber::preStart in Automatic Updates 8.2
Reacts to the beginning of an update process.
Parameters
\Drupal\automatic_updates\Event\PreStartEvent $event: The event object.
File
- src/
Event/ ExcludedPathsSubscriber.php, line 86
Class
- ExcludedPathsSubscriber
- Defines an event subscriber to exclude certain paths from update operations.
Namespace
Drupal\automatic_updates\EventCode
public function preStart(PreStartEvent $event) : void {
// Automated test site directories should never be staged.
$event
->excludePath('sites/simpletest');
// Windows server configuration files, like web.config, should never be
// staged either. (These can be written in the vendor directory by the
// core-vendor-hardening plugin, which is used in the drupal/legacy-project
// template.)
$event
->excludePath('web.config');
if ($public = $this
->getFilesPath('public')) {
$event
->excludePath($public);
}
if ($private = $this
->getFilesPath('private')) {
$event
->excludePath($private);
}
// If this module is a git clone, exclude it.
if (is_dir(__DIR__ . '/../../.git')) {
$event
->excludePath($this->fileSystem
->realpath(__DIR__ . '/../..'));
}
// Exclude site-specific settings files.
$settings_files = [
'settings.php',
'settings.local.php',
'services.yml',
];
foreach ($settings_files as $settings_file) {
$file_path = implode(DIRECTORY_SEPARATOR, [
$this->appRoot,
$this->sitePath,
$settings_file,
]);
$file_path = $this->fileSystem
->realpath($file_path);
if (file_exists($file_path)) {
$event
->excludePath($file_path);
}
$default_file_path = implode(DIRECTORY_SEPARATOR, [
'sites',
'default',
$settings_file,
]);
$event
->excludePath($default_file_path);
}
}