GrantSlugResolver
\Benecaster\Entitlement\GrantSlugResolver
Answers one question: what access does this person hold on this show that is not part of their tier? It replaces the feed’s former buy-up lookup, and it is the one place the feed and the cancellation path both ask.
It is the single place every grant is resolved, from any source. Core’s own rows and anything an add-on contributes through the benecaster_entitlement_grant_slugs filter both come out of resolve_standalone_grants(), which is why an add-on never needs to touch the feed path itself.
The class exists to hold a distinction, and getting it wrong in either direction is a real fault. A buy-up is a recurring subscription item riding on a membership, and it ends with that membership. A standalone entitlement is owned outright and survives every degradation. append() returns both and is used where the membership is intact (an ordinary subscriber, a follower). append_standalone() returns entitlements only and is used where the listener has been handed a degraded base they did not choose: the over-limit demotion and the licence grace period. Returning buy-ups on a degraded base would keep serving what the listener is no longer paying for; dropping entitlements would take away what they bought.
Constructor Dependencies
| Type | Description |
|---|---|
\Benecaster\Entitlement\EntitlementRepository |
Core's record of standalone access. Optional; defaults to a new instance. |
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
append( array $tier_slugs, int $user_id, int $show_id ): array |
Public | — | Appends every grant the person holds, buy-ups and standalone. For paths where the membership is intact. The base tier stays at index 0, because it is a published hook argument; grants are only ever appended. |
append_standalone( array $tier_slugs, int $user_id, int $show_id ): array |
Public | — | Appends standalone entitlements only. For every path that hands the listener a degraded base. Buy-ups are excluded on purpose. |
resolve_subscription_grants( int $user_id, int $show_id ): array |
Public | — | The buy-up slugs the person holds, which live and die with the subscription they were bought on. |
resolve_standalone_grants( int $user_id, int $show_id ): array |
Public | — | The grant slugs the person holds that stand on their own. Applies the benecaster_entitlement_grant_slugs filter to core's own entitlement rows and then merges core's rows back in, so the filter can add but never remove. |
has_standalone( int $user_id, int $show_id ): bool |
Public | — | Whether the person holds any standalone access on the show. Blind to buy-ups on purpose. It is what decides between refusing a listener with no membership and serving them a grants-only feed, and what decides whether a cancellation converts the token or revokes it. |