Events: Extension and action examples
Use the action functions with records and Data objects supplied by your application. They pass each argument to the package operation and return its result.
These adapters show container registration. Use the owning package registry when a contract requires contributor discovery.
Contract adapters wrap an existing implementation. Call their registration function from your service provider with that implementation; tagged contracts keep their declared tag. Resolve the backend by its concrete class before registration so the replacement contract does not resolve itself. Static contract metadata uses one backend class per adapter.
Contract Capell\Events\Contracts\EventBookingProvider
Section titled “Contract Capell\Events\Contracts\EventBookingProvider”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\Events;
final class EventBookingProviderAdapter implements \Capell\Events\Contracts\EventBookingProvider{ public function __construct(private readonly \Capell\Events\Contracts\EventBookingProvider $backend) {}
#[\Override] public function bookingUrl(\Capell\Events\Models\EventOccurrence $occurrence): ?string { return $this->backend->bookingUrl($occurrence); }
#[\Override] public function isAvailable(\Capell\Events\Models\EventOccurrence $occurrence, int $quantity): bool { return $this->backend->isAvailable($occurrence, $quantity); }}
function registerEventBookingProviderAdapter(\Capell\Events\Contracts\EventBookingProvider $backend): void{ app()->bind(EventBookingProviderAdapter::class, static fn (): EventBookingProviderAdapter => new EventBookingProviderAdapter($backend)); app()->bind(\Capell\Events\Contracts\EventBookingProvider::class, EventBookingProviderAdapter::class);}Contract Capell\Events\Contracts\EventRegistrationProvider
Section titled “Contract Capell\Events\Contracts\EventRegistrationProvider”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\Events;
final class EventRegistrationProviderAdapter implements \Capell\Events\Contracts\EventRegistrationProvider{ public function __construct(private readonly \Capell\Events\Contracts\EventRegistrationProvider $backend) {}
#[\Override] public function register(\Capell\Events\Models\EventOccurrence $occurrence, \Capell\Events\Data\EventRegistrationData $registrationData): \Capell\Events\Models\EventRegistration { return $this->backend->register($occurrence, $registrationData); }}
function registerEventRegistrationProviderAdapter(\Capell\Events\Contracts\EventRegistrationProvider $backend): void{ app()->bind(EventRegistrationProviderAdapter::class, static fn (): EventRegistrationProviderAdapter => new EventRegistrationProviderAdapter($backend)); app()->bind(\Capell\Events\Contracts\EventRegistrationProvider::class, EventRegistrationProviderAdapter::class);}Action install
Section titled “Action install”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\Events;
function runInstall(\Capell\Core\Data\PackageData $package, array $arguments = [], ?\Capell\Core\Contracts\ProgressReporter $reporter = null): void{ \Capell\Events\Actions\InstallEventsPackageAction::run($package, $arguments, $reporter);}Customer Portal ownership
Section titled “Customer Portal ownership”Event registrations are visible only when owner_type and owner_id match the
persisted PortalAccount’s durable authenticatable owner. The event-site restriction
still applies. Email verification, portal email snapshots and current or historical
email matches do not authorise registrations. Ownership survives email changes,
reconciliation and revoked mailbox verification. Unassociated legacy rows remain
suppressed, including for their original attendee.
The public registration controller passes its authenticated actor to
RegisterForEventOccurrenceAction as the optional third argument. Trusted callers
may supply that actor explicitly; background, staff and guest workflows without a
customer actor leave the association null. Submitted email and payload fields never
establish ownership.
Operator recovery
Section titled “Operator recovery”Independently establish that the customer owns the specific registration before linking it, using original booking evidence and an authenticated customer identity. Control of the booking email today is insufficient. Record the evidence and operator in your support case; do not place personal evidence in application logs.
Run these commands in the owning installed application’s Artisan environment:
php artisan capell-events:link-registration 123 'App\Models\User' 456php artisan capell-events:link-registration 123 'App\Models\User' 456 --confirmReplace 123 with the registration ID and the final two arguments with the existing
authenticatable owner’s model class (or registered morph alias) and ID. The first
command is a dry run: it validates and prints the proposed association without
writing. After checking those IDs against the independent evidence, --confirm
persists both owner columns in a null-only write and prints the link. Missing records,
invalid owners, and any complete or partial existing association are refused, even
when the supplied owner is the same. No legacy rows are bulk-claimed by email.
A confirmed write emits capell-events.registration-owner-linked to the application
log with the registration ID, canonical owner type and owner ID. Dry runs and refusals
do not emit a successful-link audit line. Verify the record in the owner’s portal
feed on the event’s site after linking. The command does not transfer registrations
that already have an owner; investigate those separately.