public function QueryAccessHandlerBase::getConditions in Entity API 8
Gets the conditions for the given operation and user.
The "entity.query_access.$entity_type_id" event is fired to allow modules to alter the conditions.
Parameters
string $operation: The access operation. Usually one of "view", "update", "duplicate", or "delete".
\Drupal\Core\Session\AccountInterface $account: The user for which to restrict access, or NULL to assume the current user. Defaults to NULL.
Return value
\Drupal\entity\QueryAccess\ConditionGroup The conditions.
Overrides QueryAccessHandlerInterface::getConditions
File
- src/
QueryAccess/ QueryAccessHandlerBase.php, line 84
Class
- QueryAccessHandlerBase
- Provides common logic for query access handlers.
Namespace
Drupal\entity\QueryAccessCode
public function getConditions($operation, AccountInterface $account = NULL) {
$account = $account ?: $this->currentUser;
$entity_type_id = $this->entityType
->id();
$conditions = $this
->buildConditions($operation, $account);
// Allow other modules to modify the conditions before they are used.
$event = new QueryAccessEvent($conditions, $operation, $account, $entity_type_id);
$this->eventDispatcher
->dispatch("entity.query_access", $event);
$this->eventDispatcher
->dispatch("entity.query_access.{$entity_type_id}", $event);
return $conditions;
}