Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SiteFilesExcluder.php

function SiteFilesExcluder::excludeSiteFiles

Excludes public and private files from stage operations.

Parameters

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

File

core/modules/package_manager/src/PathExcluder/SiteFilesExcluder.php, line 44

Class

SiteFilesExcluder
Excludes site files from stage operations.

Namespace

Drupal\package_manager\PathExcluder

Code

public function excludeSiteFiles(CollectPathsToExcludeEvent $event) : void {
    // Exclude files handled by the stream wrappers listed in $this->wrappers.
    // These paths could be either absolute or relative, depending on site
    // settings. If they are absolute, treat them as relative to the project
    // root. Otherwise, treat them as relative to the web root.
    foreach ($this->wrappers as $scheme) {
        $wrapper = $this->streamWrapperManager
            ->getViaScheme($scheme);
        if ($wrapper instanceof LocalStream) {
            $path = $wrapper->getDirectoryPath();
            if ($this->fileSystem
                ->isAbsolutePath($path)) {
                if ($path = realpath($path)) {
                    $event->addPathsRelativeToProjectRoot([
                        $path,
                    ]);
                }
            }
            else {
                $event->addPathsRelativeToWebRoot([
                    $path,
                ]);
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal