function TaxonomyTestHooks::entityAccess
Implements hook_entity_access().
File
-
core/
modules/ taxonomy/ tests/ modules/ taxonomy_test/ src/ Hook/ TaxonomyTestHooks.php, line 24
Class
- TaxonomyTestHooks
- Hook implementations for taxonomy_test.
Namespace
Drupal\taxonomy_test\HookCode
public function entityAccess(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.