Frontend Authoring: Worked extension examples
These developer-facing recipes are kept beside the package contract. Replace the example values with the site-specific records and data objects used by the calling workflow.
<?phpdeclare(strict_types=1);final class ExampleEditableRegionApprovalWorkflowImplementation implements \Capell\FrontendAuthoring\Contracts\EditableRegionApprovalWorkflow{ public function supports(\Illuminate\Database\Eloquent\Model $record): bool { throw new LogicException('Implement this package contract for the calling site.'); } /** * @param Closure(Model): void $applyValue */ public function saveForApproval(\Illuminate\Database\Eloquent\Model $record, \Illuminate\Contracts\Auth\Authenticatable $actor, string $currentUrl, \Closure $applyValue): string { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\FrontendAuthoring\Contracts\EditableRegionApprovalWorkflow::class, ExampleEditableRegionApprovalWorkflowImplementation::class);<?phpdeclare(strict_types=1);final class ExampleEditableRegionEditorSurfaceImplementation implements \Capell\FrontendAuthoring\Contracts\EditableRegionEditorSurface{ public function surface(): \Capell\FrontendAuthoring\Enums\EditableRegionSurface { throw new LogicException('Implement this package contract for the calling site.'); } public function render(\Capell\FrontendAuthoring\Data\EditableRegionPayloadData $payload, \Illuminate\Contracts\Auth\Authenticatable $user): \Illuminate\Contracts\View\View { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\FrontendAuthoring\Contracts\EditableRegionEditorSurface::class, ExampleEditableRegionEditorSurfaceImplementation::class);Install lifecycle action
Section titled “Install lifecycle action”Normal installation invokes this action through the package lifecycle. A trusted
host integration can pass the selected package’s existing PackageData record:
<?phpdeclare(strict_types=1);
function installSelectedPackage(\Capell\Core\Data\PackageData $package): void{ \Capell\FrontendAuthoring\Actions\InstallFrontendAuthoringPackageAction::run($package);}AuthoringMarkerEligibility adapter
Section titled “AuthoringMarkerEligibility adapter”This adapter delegates to the shipped implementation so the existing eligibility, ownership or pagination bounds remain in force. Resolve the backend by its concrete class to avoid resolving the replacement contract recursively.
<?phpdeclare(strict_types=1);
final class ExampleAuthoringMarkerEligibilityAdapter implements \Capell\FrontendAuthoring\Contracts\AuthoringMarkerEligibility{ public function __construct(private readonly \Capell\FrontendAuthoring\Support\DefaultAuthoringMarkerEligibility $backend) {}
#[\Override] public function isEligible(\Illuminate\Contracts\Auth\Authenticatable $user): bool { return $this->backend->isEligible($user); }}
app()->bind(\Capell\FrontendAuthoring\Contracts\AuthoringMarkerEligibility::class, ExampleAuthoringMarkerEligibilityAdapter::class);