AccessPluginBase.php 1.32 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Definition of Drupal\views\Plugin\views\access\AccessPluginBase.
6 7
 */

8
namespace Drupal\views\Plugin\views\access;
9

10
use Drupal\Core\Session\AccountInterface;
11
use Drupal\views\Plugin\views\PluginBase;
12
use Symfony\Component\Routing\Route;
13

14 15 16
/**
 * @defgroup views_access_plugins Views access plugins
 * @{
17 18
 * The base plugin to handle access to a view.
 *
19
 * Therefore it primarily has to implement the access and the alterRouteDefinition
20
 * method.
21 22 23 24 25
 */

/**
 * The base plugin to handle access control.
 */
26
abstract class AccessPluginBase extends PluginBase {
27

28
  /**
29
   * {@inheritdoc}
30
   */
31
  public function summaryTitle() {
32 33 34 35 36
    return t('Unknown');
  }

  /**
   * Determine if the current user has access or not.
37
   *
38
   * @param \Drupal\Core\Session\AccountInterface $account
39 40 41 42
   *   The user who wants to access this view.
   *
   * @return TRUE
   *   Returns whether the user has access to the view.
43
   */
44
  abstract public function access(AccountInterface $account);
45 46

  /**
47
   * Allows access plugins to alter the route definition of a view.
48
   *
49 50
   * Likely the access plugin will add new requirements, so its custom access
   * checker can be applied.
51
   *
52 53
   * @param \Symfony\Component\Routing\Route $route
   *   The route to change.
54
   */
55
  abstract public function alterRouteDefinition(Route $route);
56

57 58 59 60 61
}

/**
 * @}
 */