class EntityAccessEvent in Hook Event Dispatcher 8
Class EntityAccessEvent.
Hierarchy
- class \Drupal\hook_event_dispatcher\Event\Entity\BaseEntityEvent extends \Symfony\Component\EventDispatcher\Event implements EventInterface
- class \Drupal\hook_event_dispatcher\Event\Entity\EntityAccessEvent
Expanded class hierarchy of EntityAccessEvent
2 files declare their use of EntityAccessEvent
- EntityAccessEventTest.php in tests/
src/ Unit/ Entity/ EntityAccessEventTest.php - hook_event_dispatcher.module in ./
hook_event_dispatcher.module - Hook event dispatcher module.
File
- src/
Event/ Entity/ EntityAccessEvent.php, line 14
Namespace
Drupal\hook_event_dispatcher\Event\EntityView source
class EntityAccessEvent extends BaseEntityEvent {
/**
* The operation that is to be performed on $entity.
*
* @var string
*/
protected $operation;
/**
* The account trying to access the entity.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* The access result.
*
* @var \Drupal\Core\Access\AccessResultInterface
*/
protected $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, $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() {
return $this->operation;
}
/**
* Get the account.
*
* @return \Drupal\Core\Session\AccountInterface
* The account.
*/
public function getAccount() {
return $this->account;
}
/**
* Get the access result.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function getAccessResult() {
return $this->accessResult;
}
/**
* Set the access result.
*
* @param \Drupal\Core\Access\AccessResultInterface $accessResult
* The access result.
*
* @deprecated in favour of addAccessResult() which is more descriptive.
*/
public function setAccessResult(AccessResultInterface $accessResult) {
$this
->addAccessResult($accessResult);
}
/**
* Add the access result.
*
* @param \Drupal\Core\Access\AccessResultInterface $accessResult
* The access result.
*/
public function addAccessResult(AccessResultInterface $accessResult) {
$this->accessResult = $this->accessResult
->orIf($accessResult);
}
/**
* {@inheritdoc}
*/
public function getDispatcherType() {
return HookEventDispatcherInterface::ENTITY_ACCESS;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseEntityEvent:: |
protected | property | The Entity. | |
BaseEntityEvent:: |
public | function | Get the Entity. | |
BaseEntityEvent:: |
public | function | Set the Entity. | |
EntityAccessEvent:: |
protected | property | The access result. | |
EntityAccessEvent:: |
protected | property | The account trying to access the entity. | |
EntityAccessEvent:: |
protected | 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 | Set the access result. | |
EntityAccessEvent:: |
public | function |
EntityAccessEvent constructor. Overrides BaseEntityEvent:: |