class AccessResultForbidden in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Access/AccessResultForbidden.php \Drupal\Core\Access\AccessResultForbidden
Value object indicating a forbidden access result, with cacheability metadata.
Hierarchy
- class \Drupal\Core\Access\AccessResult implements AccessResultInterface, RefinableCacheableDependencyInterface uses RefinableCacheableDependencyTrait
- class \Drupal\Core\Access\AccessResultForbidden implements AccessResultReasonInterface
Expanded class hierarchy of AccessResultForbidden
4 files declare their use of AccessResultForbidden
- AccessResultForbiddenTest.php in core/
tests/ Drupal/ Tests/ Core/ Access/ AccessResultForbiddenTest.php - book_breadcrumb_test.module in core/
modules/ book/ tests/ modules/ book_breadcrumb_test/ book_breadcrumb_test.module - Test module for testing the book module breadcrumb.
- LatestRevisionCheckTest.php in core/
modules/ content_moderation/ tests/ src/ Unit/ LatestRevisionCheckTest.php - LocalActionManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalActionManagerTest.php - Contains \Drupal\Tests\Core\Menu\LocalActionManagerTest.
File
- core/
lib/ Drupal/ Core/ Access/ AccessResultForbidden.php, line 8
Namespace
Drupal\Core\AccessView source
class AccessResultForbidden extends AccessResult implements AccessResultReasonInterface {
/**
* The reason why access is forbidden. For use in error messages.
*
* @var string|null
*/
protected $reason;
/**
* Constructs a new AccessResultForbidden instance.
*
* @param null|string $reason
* (optional) A message to provide details about this access result.
*/
public function __construct($reason = NULL) {
$this->reason = $reason;
}
/**
* {@inheritdoc}
*/
public function isForbidden() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function getReason() {
return $this->reason;
}
/**
* {@inheritdoc}
*/
public function setReason($reason) {
$this->reason = $reason;
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccessResult:: |
public static | function | Creates an AccessResultInterface object with isAllowed() === TRUE. | |
AccessResult:: |
public static | function | Creates an allowed or neutral access result. | |
AccessResult:: |
public static | function | Creates an allowed access result if the permission is present, neutral otherwise. | |
AccessResult:: |
public static | function | Creates an allowed access result if the permissions are present, neutral otherwise. | |
AccessResult:: |
public | function |
Combine this access result with another using AND. Overrides AccessResultInterface:: |
|
AccessResult:: |
public | function | Convenience method, adds the "user.permissions" cache context. | |
AccessResult:: |
public | function | Convenience method, adds the "user" cache context. | |
AccessResult:: |
public | function | Convenience method, adds the configuration object's cache tag. | |
AccessResult:: |
public | function | Convenience method, adds the entity's cache tag. | |
AccessResult:: |
public static | function | Creates an AccessResultInterface object with isForbidden() === TRUE. | |
AccessResult:: |
public static | function | Creates a forbidden or neutral access result. | |
AccessResult:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
AccessResult:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
AccessResult:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
AccessResult:: |
public | function | Inherits the cacheability of the other access result, if any. | |
AccessResult:: |
public | function |
Overrides AccessResultInterface:: |
1 |
AccessResult:: |
public | function |
Overrides AccessResultInterface:: |
1 |
AccessResult:: |
public static | function | Creates an AccessResultInterface object with isNeutral() === TRUE. | |
AccessResult:: |
public | function |
Combine this access result with another using OR. Overrides AccessResultInterface:: |
|
AccessResult:: |
public | function | Resets cache contexts (to the empty array). | |
AccessResult:: |
public | function | Resets cache tags (to the empty array). | |
AccessResult:: |
public | function | Sets the maximum age for which this access result may be cached. | |
AccessResultForbidden:: |
protected | property | The reason why access is forbidden. For use in error messages. | |
AccessResultForbidden:: |
public | function |
Gets the reason for this access result. Overrides AccessResultReasonInterface:: |
|
AccessResultForbidden:: |
public | function |
Checks whether this access result indicates access is explicitly forbidden. Overrides AccessResult:: |
|
AccessResultForbidden:: |
public | function |
Sets the reason for this access result. Overrides AccessResultReasonInterface:: |
|
AccessResultForbidden:: |
public | function | Constructs a new AccessResultForbidden instance. | |
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function |