function SiteConfigurationExcluder::excludeSiteConfiguration

Excludes site configuration files from stage operations.

Parameters

\Drupal\package_manager\Event\CollectPathsToExcludeEvent $event: The event object.

File

core/modules/package_manager/src/PathExcluder/SiteConfigurationExcluder.php, line 37

Class

SiteConfigurationExcluder
Excludes site configuration files from stage directories.

Namespace

Drupal\package_manager\PathExcluder

Code

public function excludeSiteConfiguration(CollectPathsToExcludeEvent $event) : void {
    // These two files are never relevant to existing sites.
    $paths = [
        'sites/default/default.settings.php',
        'sites/default/default.services.yml',
    ];
    // Exclude site-specific settings files, which are always in the web root.
    // By default, Drupal core will always try to write-protect these files.
    // @see system_requirements()
    $settings_files = [
        'settings.php',
        'settings.local.php',
        'services.yml',
    ];
    foreach ($settings_files as $settings_file) {
        $paths[] = $this->sitePath . '/' . $settings_file;
        $paths[] = 'sites/default/' . $settings_file;
    }
    // Site configuration files are always excluded relative to the web root.
    $event->addPathsRelativeToWebRoot($paths);
}

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