Select Git revision
AccessPluginBase.php

#1776494 by tim.plunkett: Fix failures exposed by plugin instantiation test.
Tim Plunkett authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
AccessPluginBase.php 2.36 KiB
<?php
/**
* @file
* Definition of Drupal\views\Plugin\views\access\AccessPluginBase.
*/
namespace Drupal\views\Plugin\views\access;
use Drupal\views\Plugin\views\PluginBase;
/**
* @defgroup views_access_plugins Views access plugins
* @{
* @todo.
*
* @see hook_views_plugins()
*/
/**
* The base plugin to handle access control.
*/
abstract class AccessPluginBase extends PluginBase {
/**
* Initialize the plugin.
*
* @param $view
* The view object.
* @param $display
* The display handler.
*/
public function init(&$view, &$display) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->display = &$display;
if (is_object($display->handler)) {
$options = $display->handler->getOption('access');
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
}
/**
* Retrieve the options when this is a new access
* control plugin
*/
protected function defineOptions() { return array(); }
/**
* Provide the default form for setting options.
*/
public function buildOptionsForm(&$form, &$form_state) { }
/**
* Provide the default form form for validating options
*/
public function validateOptionsForm(&$form, &$form_state) { }
/**
* Provide the default form form for submitting options
*/
public function submitOptionsForm(&$form, &$form_state) { }
/**
* Return a string to display as the clickable title for the
* access control.
*/
public function summaryTitle() {
return t('Unknown');
}
/**
* Determine if the current user has access or not.
*
* @param Drupal\user\User $account
* The user who wants to access this view.
*
* @return TRUE
* Returns whether the user has access to the view.
*/
abstract public function access($account);
/**
* Determine the access callback and arguments.
*
* This information will be embedded in the menu in order to reduce
* performance hits during menu item access testing, which happens
* a lot.
*
* @return array
* The first item of the array should be the function to call,and the
* second item should be an array of arguments. The first item may also be
* TRUE (bool only) which will indicate no access control.
*/
abstract function get_access_callback();
}
/**
* @}
*/