class EntityAccessEvent in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/core_event_dispatcher/src/Event/Entity/EntityAccessEvent.php \Drupal\core_event_dispatcher\Event\Entity\EntityAccessEvent
Class EntityAccessEvent.
Hierarchy
- class \Drupal\core_event_dispatcher\Event\Entity\AbstractEntityEvent extends \Symfony\Component\EventDispatcher\Event implements EventInterface
- class \Drupal\core_event_dispatcher\Event\Entity\EntityAccessEvent
Expanded class hierarchy of EntityAccessEvent
2 files declare their use of EntityAccessEvent
- core_event_dispatcher.module in modules/
core_event_dispatcher/ core_event_dispatcher.module - Core event dispatcher submodule.
- EntityAccessEventTest.php in modules/
core_event_dispatcher/ tests/ src/ Unit/ Entity/ EntityAccessEventTest.php
File
- modules/
core_event_dispatcher/ src/ Event/ Entity/ EntityAccessEvent.php, line 14
Namespace
Drupal\core_event_dispatcher\Event\EntityView source
class EntityAccessEvent extends AbstractEntityEvent {
/**
* The operation that is to be performed on $entity.
*
* @var string
*/
private $operation;
/**
* The account trying to access the entity.
*
* @var \Drupal\Core\Session\AccountInterface
*/
private $account;
/**
* The access result.
*
* @var \Drupal\Core\Access\AccessResultInterface
*/
private $accessResult;
/**
* EntityAccessEvent constructor.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to check access to.
* @param string $operation
* The operation that is to be performed on $entity.
* @param \Drupal\Core\Session\AccountInterface $account
* The account trying to access the entity.
*/
public function __construct(EntityInterface $entity, string $operation, AccountInterface $account) {
parent::__construct($entity);
$this->operation = $operation;
$this->account = $account;
$this->accessResult = new AccessResultNeutral();
}
/**
* Get the operation.
*
* @return string
* The Operation.
*/
public function getOperation() : string {
return $this->operation;
}
/**
* Get the account.
*
* @return \Drupal\Core\Session\AccountInterface
* The account.
*/
public function getAccount() : AccountInterface {
return $this->account;
}
/**
* Get the access result.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function getAccessResult() : AccessResultInterface {
return $this->accessResult;
}
/**
* Add the access result.
*
* @param \Drupal\Core\Access\AccessResultInterface $accessResult
* The access result.
*/
public function addAccessResult(AccessResultInterface $accessResult) : void {
$this->accessResult = $this->accessResult
->orIf($accessResult);
}
/**
* {@inheritdoc}
*/
public function getDispatcherType() : string {
return HookEventDispatcherInterface::ENTITY_ACCESS;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractEntityEvent:: |
protected | property | The Entity. | |
AbstractEntityEvent:: |
public | function | Get the Entity. | |
EntityAccessEvent:: |
private | property | The access result. | |
EntityAccessEvent:: |
private | property | The account trying to access the entity. | |
EntityAccessEvent:: |
private | property | The operation that is to be performed on $entity. | |
EntityAccessEvent:: |
public | function | Add the access result. | |
EntityAccessEvent:: |
public | function | Get the access result. | |
EntityAccessEvent:: |
public | function | Get the account. | |
EntityAccessEvent:: |
public | function |
Get the dispatcher type. Overrides EventInterface:: |
|
EntityAccessEvent:: |
public | function | Get the operation. | |
EntityAccessEvent:: |
public | function |
EntityAccessEvent constructor. Overrides AbstractEntityEvent:: |