W3cubDocs

/Drupal 8

abstract class AccessResult

Value object for passing an access result with cacheability metadata.

The access result itself — excluding the cacheability metadata — is immutable. There are subclasses for each of the three possible access results themselves:

When using ::orIf() and ::andIf(), cacheability metadata will be merged accordingly as well.

Hierarchy

See also

\Drupal\Core\Access\AccessResultAllowed

\Drupal\Core\Access\AccessResultForbidden

\Drupal\Core\Access\AccessResultNeutral

File

core/lib/Drupal/Core/Access/AccessResult.php, line 27

Namespace

Drupal\Core\Access

Members

Name Modifiers Type Description
AccessResult::allowed public static function Creates an AccessResultInterface object with isAllowed() === TRUE.
AccessResult::allowedIf public static function Creates an allowed or neutral access result.
AccessResult::allowedIfHasPermission public static function Creates an allowed access result if the permission is present, neutral otherwise.
AccessResult::allowedIfHasPermissions public static function Creates an allowed access result if the permissions are present, neutral otherwise.
AccessResult::andIf public function Combine this access result with another using AND. Overrides AccessResultInterface::andIf
AccessResult::cachePerPermissions public function Convenience method, adds the "user.permissions" cache context.
AccessResult::cachePerUser public function Convenience method, adds the "user" cache context.
AccessResult::cacheUntilConfigurationChanges Deprecated public function Convenience method, adds the configuration object's cache tag.
AccessResult::cacheUntilEntityChanges Deprecated public function Convenience method, adds the entity's cache tag.
AccessResult::forbidden public static function Creates an AccessResultInterface object with isForbidden() === TRUE.
AccessResult::forbiddenIf public static function Creates a forbidden or neutral access result.
AccessResult::getCacheContexts public function The cache contexts associated with this object. Overrides RefinableCacheableDependencyTrait::getCacheContexts
AccessResult::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides RefinableCacheableDependencyTrait::getCacheMaxAge
AccessResult::getCacheTags public function The cache tags associated with this object. Overrides RefinableCacheableDependencyTrait::getCacheTags
AccessResult::inheritCacheability public function Inherits the cacheability of the other access result, if any.
AccessResult::isAllowed public function Overrides AccessResultInterface::isAllowed
AccessResult::isForbidden public function Overrides AccessResultInterface::isForbidden
AccessResult::isNeutral public function Overrides AccessResultInterface::isNeutral
AccessResult::neutral public static function Creates an AccessResultInterface object with isNeutral() === TRUE.
AccessResult::orIf public function Combine this access result with another using OR. Overrides AccessResultInterface::orIf
AccessResult::resetCacheContexts public function Resets cache contexts (to the empty array).
AccessResult::resetCacheTags public function Resets cache tags (to the empty array).
AccessResult::setCacheMaxAge public function Sets the maximum age for which this access result may be cached.
RefinableCacheableDependencyTrait::$cacheContexts protected property Cache contexts.
RefinableCacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
RefinableCacheableDependencyTrait::$cacheTags protected property Cache tags.
RefinableCacheableDependencyTrait::addCacheableDependency public function Adds a dependency on an object: merges its cacheability metadata. Overrides RefinableCacheableDependencyInterface::addCacheableDependency
RefinableCacheableDependencyTrait::addCacheContexts public function Adds cache contexts. Overrides RefinableCacheableDependencyInterface::addCacheContexts
RefinableCacheableDependencyTrait::addCacheTags public function Adds cache tags. Overrides RefinableCacheableDependencyInterface::addCacheTags
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function Merges the maximum age (in seconds) with the existing maximum age. Overrides RefinableCacheableDependencyInterface::mergeCacheMaxAge

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Access!AccessResult.php/class/AccessResult/8.1.x