NativeBridge
\Benecaster\Bridge\Bridges\NativeBridge
The built-in membership bridge. Implements BridgeInterface against Benecaster’s own subscription and membership tier records — read through SubscriptionRepository and MembershipTierRepository — rather than a third-party plugin. Plugin slug: benecaster_builtin.
Available on all plans.
NativeBridge is registered and activated automatically by BridgeManager — you do not instantiate it directly. Activate the built-in bridge by selecting it in the bridge picker after the activation gate conditions are met (at least one Stripe key saved and at least one active tier). The gate is evaluated by Benecaster\Bridge\NativeBridgeActivationGate.
Custom code that hooks into benecaster_subscription_activated, benecaster_token_generated, and other lifecycle actions fires for built-in membership subscribers exactly as it fires for external-bridge subscribers — no code changes required.
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
get_user_tier( int $user_id, int $show_id ): ?string |
Public | — | Resolves the subscriber's active subscription via SubscriptionRepository. Returns the active tier slug, or null if no active subscription exists. |
get_all_user_tiers( int $user_id, int $show_id ): array |
Public | — | Returns all active tier slugs for the user. Built-in membership supports one active tier per user per show — returns a single-element array or []. |
is_user_active( int $user_id, int $show_id ): bool |
Public | — | Delegates to get_user_tier(). |
get_all_tiers( int $show_id ): array |
Public | — | Reads the show's membership tiers via MembershipTierRepository. Returns all active tiers as array{id: int, name: string, price: float|null}. price is the monthly price (or annual if monthly is not set). |
dispatch_activation( int $user_id, int $show_id, string $tier_slug, string $source = 'new' ): void |
Public | — | Invokes every callback registered via on_subscription_activated(). SubscriptionListener::handle_activation() is the first registered consumer and drives token generation and the welcome email. |
dispatch_change( int $user_id, int $show_id, string $old_tier_slug, string $new_tier_slug ): void |
Public | — | Invokes every callback registered via on_subscription_changed(). SubscriptionListener::handle_tier_change() updates the token row before firing benecaster_subscription_tier_changed. |
dispatch_renewal( int $user_id, int $show_id ): void |
Public | — | Invokes every callback registered via on_subscription_renewed() and fires benecaster_subscription_renewed. |
create_manual_membership( int $user_id, int $show_id, string $tier_slug, ?string $expiry_at ): array |
Public | — | Implements BridgeInterface::create_manual_membership(). Delegates to NativeSubscriptionManager::create_manual(). Returns { subscription_id: int, token_prefix: string }. |
set_subscription_manager_factory( callable $factory ): void |
Public | — | Receives a lazy resolver for NativeSubscriptionManager, called from Plugin.php container wiring to avoid a circular constructor dependency. |
Hooks Fired
-
benecaster-subscription-renewed
Notes
Breaking semantic change (feature/built-in-membership-lifecycle): Prior to the Lifecycle batch,
on_subscription_activated(), on_subscription_changed(), and on_subscription_renewed() were no-ops —
registering a callback via them was silently ignored. As of the Lifecycle batch, all three store and invoke
callbacks. If code previously registered callbacks to these methods expecting them to be ignored, they will
now fire.
on_subscription_cancelled() and on_payment_failed() remain no-ops — those paths route through routing
actions and InvoicePaymentFailedListener / SubscriptionDeletedListener directly.