class AccessEventBase in Organic groups 8
Base class for OG access events.
Hierarchy
- class \Drupal\og\Event\AccessEventBase extends \Symfony\Component\EventDispatcher\Event implements AccessEventInterface uses RefinableCacheableDependencyTrait
Expanded class hierarchy of AccessEventBase
File
- src/
Event/ AccessEventBase.php, line 18
Namespace
Drupal\og\EventView source
class AccessEventBase extends Event implements AccessEventInterface {
use RefinableCacheableDependencyTrait;
/**
* The access result.
*
* @var \Drupal\Core\Access\AccessResultInterface
*/
protected $access;
/**
* The group that provides the context for the access check.
*
* @var \Drupal\Core\Entity\ContentEntityInterface
*/
protected $group;
/**
* The user for which to check access.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $user;
/**
* Constructs an AccessEventBase event.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $group
* The group that provides the context in which to perform the access check.
* @param \Drupal\Core\Session\AccountInterface $user
* The user for which to check access.
*/
public function __construct(ContentEntityInterface $group, AccountInterface $user) {
$this->group = $group;
$this->user = $user;
$this->access = AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
public function grantAccess() : AccessResultInterface {
$this->access = $this->access
->orIf(AccessResult::allowed());
return $this->access;
}
/**
* {@inheritdoc}
*/
public function denyAccess() : AccessResultInterface {
$this->access = $this->access
->orIf(AccessResult::forbidden());
return $this->access;
}
/**
* {@inheritdoc}
*/
public function mergeAccessResult(AccessResultInterface $access_result) : AccessResultInterface {
$this->access = $this->access
->orIf($access_result);
return $this->access;
}
/**
* {@inheritdoc}
*/
public function getGroup() : ContentEntityInterface {
return $this->group;
}
/**
* {@inheritdoc}
*/
public function getUser() : AccountInterface {
return $this->user;
}
/**
* {@inheritdoc}
*/
public function getAccessResult() : AccessResultInterface {
$access = $this->access;
// Enrich the access result object with our cacheability metadata in case it
// supports it.
if ($access instanceof RefinableCacheableDependencyInterface) {
$access
->addCacheableDependency($this);
}
return $access;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccessEventBase:: |
protected | property | The access result. | |
AccessEventBase:: |
protected | property | The group that provides the context for the access check. | |
AccessEventBase:: |
protected | property | The user for which to check access. | |
AccessEventBase:: |
public | function |
Declare that access is being denied. Overrides AccessEventInterface:: |
|
AccessEventBase:: |
public | function |
Returns the current access result object. Overrides AccessEventInterface:: |
|
AccessEventBase:: |
public | function |
Returns the group that provides the context for the access check. Overrides AccessEventInterface:: |
|
AccessEventBase:: |
public | function |
Returns the user for which access is being determined. Overrides AccessEventInterface:: |
|
AccessEventBase:: |
public | function |
Declare that access is being granted. Overrides AccessEventInterface:: |
|
AccessEventBase:: |
public | function |
Merges the given access result with the existing access result. Overrides AccessEventInterface:: |
|
AccessEventBase:: |
public | function | Constructs an AccessEventBase event. | 1 |
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function |