Skip to content
Snippets Groups Projects
Select Git revision
  • b88ea0734084bcbc75d19c89b2c00d3a5ece526d
  • 11.x default protected
  • 10.5.x protected
  • 11.2.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
41 results

AccessPluginBase.php

Blame
  • Tim Plunkett's avatar
    Issue #1776494 by tim.plunkett: Fix failures exposed by plugin instantiation test.
    Tim Plunkett authored
    b88ea073
    History
    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();
    
    }
    
    /**
     * @}
     */