class AccessResultNeutral

Same name in other branches
  1. 9 core/lib/Drupal/Core/Access/AccessResultNeutral.php \Drupal\Core\Access\AccessResultNeutral
  2. 8.9.x core/lib/Drupal/Core/Access/AccessResultNeutral.php \Drupal\Core\Access\AccessResultNeutral
  3. 11.x core/lib/Drupal/Core/Access/AccessResultNeutral.php \Drupal\Core\Access\AccessResultNeutral

Value object indicating a neutral access result, with cacheability metadata.

Hierarchy

Expanded class hierarchy of AccessResultNeutral

7 files declare their use of AccessResultNeutral
AccessResultNeutralTest.php in core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php
AccessResultTest.php in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
AnnounceBlockTest.php in core/modules/announcements_feed/tests/src/FunctionalJavascript/AnnounceBlockTest.php
BlockContentAccessHandlerTest.php in core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php
BlockPluginHasSettingsTrayFormAccessCheckTest.php in core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php

... See full list

File

core/lib/Drupal/Core/Access/AccessResultNeutral.php, line 8

Namespace

Drupal\Core\Access
View source
class AccessResultNeutral extends AccessResult implements AccessResultReasonInterface {
    
    /**
     * The reason why access is neutral. For use in messages.
     *
     * @var string
     */
    protected $reason;
    
    /**
     * Constructs a new AccessResultNeutral 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 isNeutral() {
        return TRUE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getReason() {
        return (string) $this->reason;
    }
    
    /**
     * {@inheritdoc}
     */
    public function setReason($reason) {
        $this->reason = $reason;
        return $this;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
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 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::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 Overrides CacheableDependencyTrait::getCacheContexts
AccessResult::getCacheMaxAge public function Overrides CacheableDependencyTrait::getCacheMaxAge
AccessResult::getCacheTags public function Overrides CacheableDependencyTrait::getCacheTags
AccessResult::inheritCacheability public function Inherits the cacheability of the other access result, if any.
AccessResult::isAllowed public function Overrides AccessResultInterface::isAllowed 1
AccessResult::isForbidden public function Overrides AccessResultInterface::isForbidden 1
AccessResult::neutral public static function Creates an AccessResultInterface object with isNeutral() === TRUE.
AccessResult::orIf public function 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.
AccessResultNeutral::$reason protected property The reason why access is neutral. For use in messages.
AccessResultNeutral::getReason public function Overrides AccessResultReasonInterface::getReason
AccessResultNeutral::isNeutral public function Overrides AccessResult::isNeutral
AccessResultNeutral::setReason public function Overrides AccessResultReasonInterface::setReason
AccessResultNeutral::__construct public function Constructs a new AccessResultNeutral instance.
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.