class StaticTest

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php \Drupal\views_test_data\Plugin\views\access\StaticTest
  2. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php \Drupal\views_test_data\Plugin\views\access\StaticTest
  3. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php \Drupal\views_test_data\Plugin\views\access\StaticTest

Tests a static access plugin.

Plugin annotation


@ViewsAccess(
  id = "test_static",
  title = @Translation("Static test access plugin"),
  help = @Translation("Provides a static test access plugin.")
)

Hierarchy

Expanded class hierarchy of StaticTest

6 string references to 'StaticTest'
DisplayPageTest::testDependencies in core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
Tests the calculated dependencies for various views using Page displays.
StaticTest::calculateDependencies in core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php
ViewEntityDependenciesTest::testGetDependencies in core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
Tests the getDependencies method.
views.view.test_access_static.yml in core/modules/views/tests/modules/views_test_data/test_views/views.view.test_access_static.yml
core/modules/views/tests/modules/views_test_data/test_views/views.view.test_access_static.yml
views.view.test_page_display_route.yml in core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_route.yml
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_route.yml

... See full list

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php, line 18

Namespace

Drupal\views_test_data\Plugin\views\access
View source
class StaticTest extends AccessPluginBase {
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['access'] = [
      'default' => FALSE,
    ];
    return $options;
  }
  
  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account) {
    return !empty($this->options['access']);
  }
  
  /**
   * {@inheritdoc}
   */
  public function alterRouteDefinition(Route $route) {
    if (!empty($this->options['access'])) {
      $route->setRequirement('_access', 'TRUE');
    }
  }
  
  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    return [
      'content' => [
        'StaticTest',
      ],
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.