class UncacheableTestAccessResult

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\UncacheableTestAccessResult
  2. 8.9.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\UncacheableTestAccessResult
  3. 11.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\UncacheableTestAccessResult

Hierarchy

Expanded class hierarchy of UncacheableTestAccessResult

File

core/tests/Drupal/Tests/Core/Access/AccessResultTest.php, line 973

Namespace

Drupal\Tests\Core\Access
View source
class UncacheableTestAccessResult implements AccessResultInterface {
  
  /**
   * The access result value. 'ALLOWED', 'FORBIDDEN' or 'NEUTRAL'.
   *
   * @var string
   */
  protected $value;
  
  /**
   * Constructs a new UncacheableTestAccessResult object.
   */
  public function __construct($value) {
    $this->value = $value;
  }
  
  /**
   * {@inheritdoc}
   */
  public function isAllowed() {
    return $this->value === 'ALLOWED';
  }
  
  /**
   * {@inheritdoc}
   */
  public function isForbidden() {
    return $this->value === 'FORBIDDEN';
  }
  
  /**
   * {@inheritdoc}
   */
  public function isNeutral() {
    return $this->value === 'NEUTRAL';
  }
  
  /**
   * {@inheritdoc}
   */
  public function orIf(AccessResultInterface $other) {
    if ($this->isForbidden() || $other->isForbidden()) {
      return new static('FORBIDDEN');
    }
    elseif ($this->isAllowed() || $other->isAllowed()) {
      return new static('ALLOWED');
    }
    else {
      return new static('NEUTRAL');
    }
  }
  
  /**
   * {@inheritdoc}
   */
  public function andIf(AccessResultInterface $other) {
    if ($this->isForbidden() || $other->isForbidden()) {
      return new static('FORBIDDEN');
    }
    elseif ($this->isAllowed() && $other->isAllowed()) {
      return new static('ALLOWED');
    }
    else {
      return new static('NEUTRAL');
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
UncacheableTestAccessResult::$value protected property The access result value. 'ALLOWED', 'FORBIDDEN' or 'NEUTRAL'.
UncacheableTestAccessResult::andIf public function Combine this access result with another using AND. Overrides AccessResultInterface::andIf
UncacheableTestAccessResult::isAllowed public function Checks whether this access result indicates access is explicitly allowed. Overrides AccessResultInterface::isAllowed
UncacheableTestAccessResult::isForbidden public function Checks whether this access result indicates access is explicitly forbidden. Overrides AccessResultInterface::isForbidden
UncacheableTestAccessResult::isNeutral public function Checks whether this access result indicates access is not yet determined. Overrides AccessResultInterface::isNeutral
UncacheableTestAccessResult::orIf public function Combine this access result with another using OR. Overrides AccessResultInterface::orIf
UncacheableTestAccessResult::__construct public function Constructs a new UncacheableTestAccessResult object.

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