StaticTest.php in Zircon Profile 8.0
File
core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php
View source
<?php
namespace Drupal\views_test_data\Plugin\views\access;
use Drupal\Core\Session\AccountInterface;
use Drupal\views\Plugin\views\access\AccessPluginBase;
use Symfony\Component\Routing\Route;
class StaticTest extends AccessPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
$options['access'] = array(
'default' => FALSE,
);
return $options;
}
public function access(AccountInterface $account) {
return !empty($this->options['access']);
}
public function alterRouteDefinition(Route $route) {
if (!empty($this->options['access'])) {
$route
->setRequirement('_access', 'TRUE');
}
}
public function calculateDependencies() {
return [
'content' => [
'StaticTest',
],
];
}
}