You are here

public function ExcludePathSubscriber::collectPaths in Tome 8

Reacts to a collect paths event.

Parameters

\Drupal\tome_static\Event\CollectPathsEvent $event: The collect paths event.

File

modules/tome_static/src/EventSubscriber/ExcludePathSubscriber.php, line 51

Class

ExcludePathSubscriber
Excludes a paths from static generation.

Namespace

Drupal\tome_static\EventSubscriber

Code

public function collectPaths(CollectPathsEvent $event) {
  $excluded_paths = self::getExcludedPaths();
  $paths = $event
    ->getPaths(TRUE);
  foreach ($paths as $path => $metadata) {
    if (in_array($path, $excluded_paths, TRUE) || isset($metadata['original_path']) && in_array($metadata['original_path'], $excluded_paths, TRUE)) {
      unset($paths[$path]);
    }
  }
  $event
    ->replacePaths($paths);
}