MenuAccessControlHandler
class MenuAccessControlHandler extends EntityAccessControlHandler (View source)
Defines the access control handler for the menu entity type.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Provides dependency injection friendly methods for serialization.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected ModuleHandlerInterface | $moduleHandler | The module handler to invoke hooks on. |
from EntityHandlerBase |
| protected array | $accessCache | Stores calculated access check results. |
from EntityAccessControlHandler |
| protected string | $entityTypeId | The entity type ID of the access control handler instance. |
from EntityAccessControlHandler |
| protected EntityTypeInterface | $entityType | Information about the entity type. |
from EntityAccessControlHandler |
| protected | $viewLabelOperation | {@inheritdoc} |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Checks access to an operation on a given entity or entity translation.
We grant access to the entity if both of these conditions are met:
- No modules say to deny access.
Performs access checks.
Tries to retrieve a previously cached access value from the static cache.
Statically caches whether the given user has access.
Checks access to create an entity.
Performs create access checks.
Loads the current account object, if it does not exist yet.
Checks access to an operation on a given entity field.
Default field access as determined by this access control handler.
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
protected ModuleHandlerInterface
moduleHandler()
Gets the module handler.
$this
setModuleHandler(ModuleHandlerInterface $module_handler)
Sets the module handler for this handler.
__construct(EntityTypeInterface $entity_type)
Constructs an access control handler instance.
bool|AccessResultInterface
access(EntityInterface $entity, string $operation, AccountInterface $account = NULL, bool $return_as_object = FALSE)
Checks access to an operation on a given entity or entity translation.
Use \Drupal\Core\Entity\EntityAccessControlHandlerInterface::createAccess() to check access to create an entity.
protected AccessResultInterface
processAccessHookResults(array $access)
We grant access to the entity if both of these conditions are met:
- No modules say to deny access.
- At least one module says to grant access.
protected AccessResultInterface
checkAccess(EntityInterface $entity, string $operation, AccountInterface $account)
Performs access checks.
This method is supposed to be overwritten by extending classes that do their own custom access checking.
protected AccessResultInterface|null
getCache(string $cid, string $operation, string $langcode, AccountInterface $account)
Tries to retrieve a previously cached access value from the static cache.
protected AccessResultInterface
setCache(AccessResultInterface $access, string $cid, string $operation, string $langcode, AccountInterface $account)
Statically caches whether the given user has access.
resetCache()
Clears all cached access checks.
bool|AccessResultInterface
createAccess(string $entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], bool $return_as_object = FALSE)
Checks access to create an entity.
protected AccessResultInterface
checkCreateAccess(AccountInterface $account, array $context, string|null $entity_bundle = NULL)
Performs create access checks.
This method is supposed to be overwritten by extending classes that do their own custom access checking.
protected AccountInterface
prepareUser(AccountInterface $account = NULL)
Loads the current account object, if it does not exist yet.
bool|AccessResultInterface
fieldAccess(string $operation, FieldDefinitionInterface $field_definition, AccountInterface $account = NULL, FieldItemListInterface $items = NULL, bool $return_as_object = FALSE)
Checks access to an operation on a given entity field.
This method does not determine whether access is granted to the entity itself, only the specific field. Callers are responsible for ensuring that entity access is also respected, for example by using \Drupal\Core\Entity\EntityAccessControlHandlerInterface::access().
protected AccessResultInterface
checkFieldAccess(string $operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL)
Default field access as determined by this access control handler.