interface AccessResultInterface (View source)

Interface for access result value objects.

IMPORTANT NOTE: You have to call isAllowed() when you want to know whether someone has access. Just using

Methods

bool
isAllowed()

Checks whether this access result indicates access is explicitly allowed.

bool
isForbidden()

Checks whether this access result indicates access is explicitly forbidden.

bool
isNeutral()

Checks whether this access result indicates access is not yet determined.

orIf(AccessResultInterface $other)

Combine this access result with another using OR.

andIf(AccessResultInterface $other)

Combine this access result with another using AND.

Details

bool isAllowed()

Checks whether this access result indicates access is explicitly allowed.

Return Value

bool

When TRUE then isForbidden() and isNeutral() are FALSE.

bool isForbidden()

Checks whether this access result indicates access is explicitly forbidden.

This is a kill switch — both orIf() and andIf() will result in isForbidden() if either results are isForbidden().

Return Value

bool

When TRUE then isAllowed() and isNeutral() are FALSE.

bool isNeutral()

Checks whether this access result indicates access is not yet determined.

Return Value

bool

When TRUE then isAllowed() and isForbidden() are FALSE.

AccessResultInterface orIf(AccessResultInterface $other)

Combine this access result with another using OR.

When ORing two access results, the result is:

  • isForbidden() in either ⇒ isForbidden()
  • otherwise if isAllowed() in either ⇒ isAllowed()
  • otherwise both must be isNeutral() ⇒ isNeutral()

Truth table:

Parameters

AccessResultInterface $other

The other access result to OR this one with.

Return Value

AccessResultInterface

AccessResultInterface andIf(AccessResultInterface $other)

Combine this access result with another using AND.

When ANDing two access results, the result is:

  • isForbidden() in either ⇒ isForbidden()
  • otherwise, if isAllowed() in both ⇒ isAllowed()
  • otherwise, one of them is isNeutral() ⇒ isNeutral()

Truth table:

Parameters

AccessResultInterface $other

The other access result to AND this one with.

Return Value

AccessResultInterface