class ChangeApprovalContext (View source)

Answers what the change-approval feature means for one user: whether it is on, how their edits to a zone are handled, which zones they review, and how many requests are waiting.

The caller supplies the user id, so nothing here reads the session and every answer is reproducible in a test.

Methods

__construct(ConfigurationInterface $config, Closure $permissions, Closure $zones, Closure $requests)

The collaborators arrive as factories: with approval turned off every question is answered from configuration alone, and nothing below should open a repository for an answer it will not use.

bool
enabled()

No description

string
modeForZone(int|null $userId, int $zoneId)

How the user's changes to the zone are handled: written directly, filed as a change request, or refused (one of ChangeApprovalPolicy::MODE_*). With approval.enabled off this is today's edit check.

bool
canReviewZone(int|null $userId, int $zoneId)

Whether the user may approve or reject change requests for the zone.

bool
hasReviewerOtherThan(array $userIds, int $zoneId, int|null $requesterId)

Whether any of the given users other than the requester may review requests for the zone. Holders of both levels at "all" qualify without a per-zone lookup; ownership is read only for users with an "own" level, and only when no such user exists.

array|null
reviewScope(int|null $userId)

The zones whose change requests the user reviews, in the shape the request repository filters take: null for every zone, [] for none, otherwise the owned zone ids.

array
pendingByZone(int|null $userId, array $zoneIds)

Pending change requests per zone for a zone list, empty when the feature is off or the user neither files nor reviews requests.

int|null
pendingReviewCount(int|null $userId)

Pending requests awaiting the user's review, for the navigation badge; null while the requests table does not exist yet, so the entry can be hidden.

Details

__construct(ConfigurationInterface $config, Closure $permissions, Closure $zones, Closure $requests)

The collaborators arrive as factories: with approval turned off every question is answered from configuration alone, and nothing below should open a repository for an answer it will not use.

Parameters

ConfigurationInterface $config
Closure $permissions
Closure $zones
Closure $requests

bool enabled()

No description

Return Value

bool

string modeForZone(int|null $userId, int $zoneId)

How the user's changes to the zone are handled: written directly, filed as a change request, or refused (one of ChangeApprovalPolicy::MODE_*). With approval.enabled off this is today's edit check.

Parameters

int|null $userId
int $zoneId

Return Value

string

bool canReviewZone(int|null $userId, int $zoneId)

Whether the user may approve or reject change requests for the zone.

Parameters

int|null $userId
int $zoneId

Return Value

bool

bool hasReviewerOtherThan(array $userIds, int $zoneId, int|null $requesterId)

Whether any of the given users other than the requester may review requests for the zone. Holders of both levels at "all" qualify without a per-zone lookup; ownership is read only for users with an "own" level, and only when no such user exists.

Parameters

array $userIds

active users

int $zoneId
int|null $requesterId

Return Value

bool

array|null reviewScope(int|null $userId)

The zones whose change requests the user reviews, in the shape the request repository filters take: null for every zone, [] for none, otherwise the owned zone ids.

Parameters

int|null $userId

Return Value

array|null

array pendingByZone(int|null $userId, array $zoneIds)

Pending change requests per zone for a zone list, empty when the feature is off or the user neither files nor reviews requests.

Parameters

int|null $userId
array $zoneIds

Return Value

array

int|null pendingReviewCount(int|null $userId)

Pending requests awaiting the user's review, for the navigation badge; null while the requests table does not exist yet, so the entry can be hidden.

Parameters

int|null $userId

Return Value

int|null