Skip to content
Corex

AccessRequestStore

Corex\Access\AccessRequestStore · interface · Core layer

createUnlessPending(int $requesterId, ?string $abilityKey, ?string $areaKey, string $reason, DateTimeImmutable $createdAt, DateTimeImmutable $expiresAt): ?int

Section titled “createUnlessPending(int $requesterId, ?string $abilityKey, ?string $areaKey, string $reason, DateTimeImmutable $createdAt, DateTimeImmutable $expiresAt): ?int”

Stores a request, unless this requester already has an open one for the same ability or area. The question and the storing are one step. A caller that asked {@see pendingFor()} and then stored would let two asks that arrive together both find nothing open, and a second press of a button is exactly two asks that arrive together. So there is no way to store a request without the question being asked.

transition(int $id, string $state, int $reviewerId, string $note, DateTimeImmutable $reviewedAt): bool

Section titled “transition(int $id, string $state, int $reviewerId, string $note, DateTimeImmutable $reviewedAt): bool”

pendingFor(int $requesterId, ?string $abilityKey, ?string $areaKey): ?array

Section titled “pendingFor(int $requesterId, ?string $abilityKey, ?string $areaKey): ?array”

The one open request this requester already has for this ability or area, if any. Exactly one of $abilityKey / $areaKey is non-null, matching what a request is stored with — asking for “any pending request by this user” would suppress a legitimate second request for a different screen, which is a worse failure than showing the form twice.

approve(int $id, int $reviewerId, string $note, DateTimeImmutable $reviewedAt, DateTimeImmutable $grantExpiresAt): bool

Section titled “approve(int $id, int $reviewerId, string $note, DateTimeImmutable $reviewedAt, DateTimeImmutable $grantExpiresAt): bool”

Approves a pending request: the request becomes a grant that ends at $grantExpiresAt.

The grants that stand: approved and not ended, newest first.

endGrant(int $id, string $reason, ?int $endedBy, DateTimeImmutable $endedAt): bool

Section titled “endGrant(int $id, string $reason, ?int $endedBy, DateTimeImmutable $endedAt): bool”

Ends a standing grant, once.

expiredGrants(DateTimeImmutable $now): array

Section titled “expiredGrants(DateTimeImmutable $now): array”

The standing grants whose expiry is at or before $now.

cancel(int $id, string $reason, DateTimeImmutable $cancelledAt): bool

Section titled “cancel(int $id, string $reason, DateTimeImmutable $cancelledAt): bool”

Cancels a pending request, once, keeping why.