You are here

public function FilterInUse::access in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 modules/video_embed_wysiwyg/src/Access/FilterInUse.php \Drupal\video_embed_wysiwyg\Access\FilterInUse::access()

Check if the filter is used for the given filter.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route: The route.

Return value

\Drupal\Core\Access\AccessResult An access result.

File

modules/video_embed_wysiwyg/src/Access/FilterInUse.php, line 23

Class

FilterInUse
An access check to ensure the form can be used only if the filter is enabled.

Namespace

Drupal\video_embed_wysiwyg\Access

Code

public function access(RouteMatchInterface $route) {
  $filter = $route
    ->getParameter('filter_format');
  if (!$filter || empty($filter
    ->filters()
    ->get('video_embed_wysiwyg')
    ->getConfiguration()['status'])) {
    return AccessResult::forbidden()
      ->addCacheableDependency($filter);
  }
  return AccessResult::allowed()
    ->addCacheableDependency($filter);
}