ViewsAccessCheck.php 905 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\views\ViewsAccessCheck.
 */

namespace Drupal\views;

10
use Drupal\Core\Access\AccessCheckInterface;
11
use Drupal\Core\Session\AccountInterface;
12 13 14 15 16 17 18
use Symfony\Component\Routing\Route;

/**
 * Defines a route access checker for the _access_all_views permission.
 *
 * @todo We could leverage the permission one as well?
 */
19
class ViewsAccessCheck implements AccessCheckInterface {
20 21

  /**
22
   * {@inheritdoc}
23
   */
24 25
  public function applies(Route $route) {
    return $route->hasDefault('view_id');
26 27 28
  }

  /**
29 30 31 32 33 34 35
   * Checks access.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   *
   * @return string
   *   A \Drupal\Core\Access\AccessInterface constant value.
36
   */
37 38
  public function access(AccountInterface $account) {
    return $account->hasPermission('access all views') ? static::ALLOW : static::DENY;
39 40 41
  }

}