You are here

public function CacheInvalidator::invalidateByPath in Decoupled Router 8

Same name and namespace in other branches
  1. 2.x src/CacheInvalidator.php \Drupal\decoupled_router\CacheInvalidator::invalidateByPath()

Invalidate cached responses associated with the given path.

This is called whenever an URL alias is created, updated or deleted and makes sure the relevant Decoupled Router responses are invalidated.

Parameters

array $path: The path array.

Throws

\Drupal\Component\Plugin\Exception\PluginException

See also

https://www.drupal.org/project/drupal/issues/2480077

File

src/CacheInvalidator.php, line 52

Class

CacheInvalidator
Invalidates decoupled router cache entries based on path events.

Namespace

Drupal\decoupled_router

Code

public function invalidateByPath($path) {

  // Derive cache tags by source path.
  $tags = $this
    ->getTagsBySourcePath($path['source']);

  // Path changes may change a cached 403 or 404 response.
  $tags = Cache::mergeTags($tags, [
    '4xx-response',
  ]);
  $this->invalidator
    ->invalidateTags($tags);
}