DynamicTest.php 1.06 KB
Newer Older
merlinofchaos's avatar
merlinofchaos committed
1 2 3 4
<?php

/**
 * @file
aspilicious's avatar
aspilicious committed
5
 * Definition of Drupal\views_test\Plugin\views\access\DynamicTest.
merlinofchaos's avatar
merlinofchaos committed
6 7
 */

aspilicious's avatar
aspilicious committed
8 9
namespace Drupal\views_test\Plugin\views\access;

10
use Drupal\Core\Annotation\Plugin;
aspilicious's avatar
aspilicious committed
11 12
use Drupal\views\Plugin\views\access\AccessPluginBase;

merlinofchaos's avatar
merlinofchaos committed
13 14
/**
 * Tests a dynamic access plugin.
aspilicious's avatar
aspilicious committed
15 16 17
 *
 * @Plugin(
 *   plugin_id = "test_dynamic",
18 19
 *   title = "Dynamic test access plugin.",
 *   help = "Provides a dynamic test access plugin."
aspilicious's avatar
aspilicious committed
20
 * )
merlinofchaos's avatar
merlinofchaos committed
21
 */
aspilicious's avatar
aspilicious committed
22
class DynamicTest extends AccessPluginBase {
merlinofchaos's avatar
merlinofchaos committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  function option_definition() {
    $options = parent::option_definition();
    $options['access'] = array('default' => FALSE, 'bool' => TRUE);

    return $options;
  }

  function access($account) {
    return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == variable_get('test_dynamic_access_argument1', NULL) && isset($this->view->args[1]) && $this->view->args[1] == variable_get('test_dynamic_access_argument2', NULL);
  }

  function get_access_callback() {
    return array('views_test_test_dynamic_access_callback', array(!empty($options['access']), 1, 2));
  }
}