class AccessPluginBase
Same name and namespace in other branches
- 11.x core/modules/views/src/Plugin/views/access/AccessPluginBase.php \Drupal\views\Plugin\views\access\AccessPluginBase
- 10 core/modules/views/src/Plugin/views/access/AccessPluginBase.php \Drupal\views\Plugin\views\access\AccessPluginBase
- 8.9.x core/modules/views/src/Plugin/views/access/AccessPluginBase.php \Drupal\views\Plugin\views\access\AccessPluginBase
The base plugin to handle access control.
Access plugins are responsible for controlling a user's access to the view. Views includes plugins for checking user roles and individual permissions.
To define an access control plugin, extend this base class. Your access plugin should have an annotation that includes the plugin's metadata, for example: @Plugin( id = "denyall", title = @Translation("No Access"), help = @Translation("Will not be accessible.") ) The definition should include the following keys:
- id: The unique identifier of your access plugin.
- title: The human-readable name for your access plugin.
- help: A short help message for your plugin.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait implements \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase extends \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface implements \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\access\AccessPluginBase implements \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase extends \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface implements \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait implements \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of AccessPluginBase
See also
\Drupal\views\Plugin\ViewsPluginManager
Related topics
5 files declare their use of AccessPluginBase
- CacheableMetadataCalculationTest.php in core/
modules/ views/ tests/ modules/ views_test_cacheable_metadata_calculation/ src/ Plugin/ views/ access/ CacheableMetadataCalculationTest.php - DisplayKernelTest.php in core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayKernelTest.php - Permission.php in core/
modules/ user/ src/ Plugin/ views/ access/ Permission.php - Role.php in core/
modules/ user/ src/ Plugin/ views/ access/ Role.php - StaticTest.php in core/
modules/ views/ tests/ modules/ views_test_data/ src/ Plugin/ views/ access/ StaticTest.php
File
-
core/
modules/ views/ src/ Plugin/ views/ access/ AccessPluginBase.php, line 46
Namespace
Drupal\views\Plugin\views\accessView source
abstract class AccessPluginBase extends PluginBase {
/**
* {@inheritdoc}
*/
public function summaryTitle() {
return $this->t('Unknown');
}
/**
* Determine if the current user has access or not.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The user who wants to access this view.
*
* @return bool
* Returns whether the user has access to the view.
*/
abstract public function access(AccountInterface $account);
/**
* Allows access plugins to alter the route definition of a view.
*
* Likely the access plugin will add new requirements, so its custom access
* checker can be applied.
*
* @param \Symfony\Component\Routing\Route $route
* The route to change.
*/
abstract public function alterRouteDefinition(Route $route);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.