DefinedTestAccessCheck.php in Drupal 9
Same filename and directory in other branches
Namespace
Drupal\router_test\AccessFile
core/modules/system/tests/modules/router_test_directory/src/Access/DefinedTestAccessCheck.phpView source
<?php
namespace Drupal\router_test\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Symfony\Component\Routing\Route;
/**
* Defines an access checker similar to DefaultAccessCheck.
*/
class DefinedTestAccessCheck implements AccessInterface {
/**
* Checks access.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access(Route $route) {
if ($route
->getRequirement('_test_access') === 'TRUE') {
return AccessResult::allowed();
}
elseif ($route
->getRequirement('_test_access') === 'FALSE') {
return AccessResult::forbidden();
}
else {
return AccessResult::neutral();
}
}
}
Classes
Name | Description |
---|---|
DefinedTestAccessCheck | Defines an access checker similar to DefaultAccessCheck. |