PromotionService
\Benecaster\Bridge\PromotionService
Drives the Promote to Bridge wizard’s run step and grace period management. Creates subscriber accounts in the target bridge via BridgeWritable::create_member(), writes grace period dates, and coordinates post-run reporting. Native subscription records and feed tokens are intentionally left intact — the existing Benecaster subscription is not cancelled.
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
build_preview( int $show_id, string $target_bridge_slug, array $tier_map ): array |
Public | — | Returns a preview of the promotion run without executing it — subscriber counts per mapped tier. Returns [ 'tiers' => [...], 'total' => N ]. |
run( int $show_id, string $target_bridge_slug, array $tier_map, int $grace_days ): array |
Public | — | Executes the promotion. Calls BridgeWritable::create_member() for each active subscriber, writes grace period dates, fires benecaster_bridge_promote_complete. Returns [ promoted, skipped, errors, grace_period_ends_at ]. $grace_days is a per-row-overridable DEFAULT, not a flat value applied to everyone: benecaster_promote_grace_length_days runs once per transferred row and can vary it, so the returned grace_period_ends_at is the baseline that was passed in rather than a summary of what each row received. Read promote_grace_period_ends_at per row when that filter is in play. |
clear_grace_period( int $subscription_id ): bool |
Public | — | Clears the promote_grace_period_ends_at marker on a subscriber record, re-enables token access and fires benecaster_promote_grace_cleared. Reads the row BEFORE the write so the action can hand listeners the pre-clear snapshot — clearing nulls both promote_grace_period_ends_at and promoted_to_bridge, so a post-write read would have lost the cancelled deadline and the destination bridge. Returns true on success, false when the record is not found. |
extend_grace_period( int $subscription_id, int $days ): bool |
Public | — | Adds $days to the subscriber's current promote_grace_period_ends_at and fires benecaster_promote_grace_extended. The addition is always measured from the STORED end date, even when that date is already in the past — extending a row that lapsed a week ago by three days leaves it still expired. $days is floored to 1. benecaster_promote_grace_length_days deliberately does not apply here, so the number the podcaster typed is used as typed. Returns false when no row has that id or the row has no grace period set. |
Hooks Fired
Notes
The grace-period expiry path does not live here. GracePeriodExpiryCheck is the daily cron that revokes lapsed rows, fires benecaster_promote_grace_expired, and offers each row to benecaster_promote_grace_expiry_should_revoke first. This class owns the promotion run and the two manual operations a podcaster performs from the Promotion History panel.