function taxonomy_test_entity_access
Implements hook_entity_access().
File
-
core/
modules/ taxonomy/ tests/ modules/ taxonomy_test/ taxonomy_test.module, line 21
Code
function taxonomy_test_entity_access(EntityInterface $entity, string $operation, AccountInterface $account) : AccessResultInterface {
if ($entity instanceof TermInterface) {
$parts = explode(' ', (string) $entity->label());
if (in_array('Inaccessible', $parts, TRUE) && in_array($operation, $parts, TRUE)) {
return AccessResult::forbidden();
}
}
return AccessResult::neutral();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.