Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / video_embed_field / modules / video_embed_wysiwyg / src / Access / FilterInUse.php
1 <?php
2
3 namespace Drupal\video_embed_wysiwyg\Access;
4
5 use Drupal\Core\Access\AccessResult;
6 use Drupal\Core\Routing\Access\AccessInterface;
7 use Drupal\Core\Routing\RouteMatchInterface;
8
9 /**
10  * An access check to ensure the form can be used only if the filter is enabled.
11  */
12 class FilterInUse implements AccessInterface {
13
14   /**
15    * Check if the filter is used for the given filter.
16    *
17    * @param \Drupal\Core\Routing\RouteMatchInterface $route
18    *   The route.
19    *
20    * @return \Drupal\Core\Access\AccessResult
21    *   An access result.
22    */
23   public function access(RouteMatchInterface $route) {
24     $filter = $route->getParameter('filter_format');
25     if (!$filter || empty($filter->filters()->get('video_embed_wysiwyg')->getConfiguration()['status'])) {
26       return AccessResult::forbidden()->addCacheableDependency($filter);
27     }
28     return AccessResult::allowed()->addCacheableDependency($filter);
29   }
30
31 }