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 ExampleBlockDefinitionProviderImplementation implements \Capell\BlockLibrary\Contracts\BlockDefinitionProvider{ /** * @return iterable<BlockDefinitionData> */ public function definitions(): iterable { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\BlockLibrary\Contracts\BlockDefinitionProvider::class, ExampleBlockDefinitionProviderImplementation::class);<?phpdeclare(strict_types=1);final class ExampleBlockDemoContentProviderImplementation implements \Capell\BlockLibrary\Contracts\BlockDemoContentProvider{ /** * @return array<string, mixed> */ public function demoContent(\Capell\BlockLibrary\Data\BlockDefinitionData $definition): array { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\BlockLibrary\Contracts\BlockDemoContentProvider::class, ExampleBlockDemoContentProviderImplementation::class);<?phpdeclare(strict_types=1);final class ExampleBlockFixtureProviderImplementation implements \Capell\BlockLibrary\Contracts\BlockFixtureProvider{ /** * @return iterable<BlockFixtureData> */ public function fixtures(\Capell\BlockLibrary\Data\BlockDefinitionData $definition): iterable { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\BlockLibrary\Contracts\BlockFixtureProvider::class, ExampleBlockFixtureProviderImplementation::class);<?phpdeclare(strict_types=1);final class ExampleBlockRendererImplementation implements \Capell\BlockLibrary\Contracts\BlockRenderer{ /** * @param array<string, mixed> $state */ public function render(\Capell\BlockLibrary\Data\BlockDefinitionData $definition, array $state = []): \Illuminate\Contracts\Support\Htmlable|string { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\BlockLibrary\Contracts\BlockRenderer::class, ExampleBlockRendererImplementation::class);<?phpdeclare(strict_types=1);final class ExampleFilamentBuilderBlockImplementation implements \Capell\BlockLibrary\Contracts\FilamentBuilderBlock{ public static function getBuilderBlockName(): string { throw new LogicException('Implement this package contract for the calling site.'); } public static function make(): \Filament\Forms\Components\Builder\Block { throw new LogicException('Implement this package contract for the calling site.'); }}
app()->bind(\Capell\BlockLibrary\Contracts\FilamentBuilderBlock::class, ExampleFilamentBuilderBlockImplementation::class);<?phpdeclare(strict_types=1);$inputs = []; // Supply the arguments required by the action handle() method.resolve(\Capell\BlockLibrary\Actions\SanitizeBlockHtmlAction::class)->handle(...$inputs);