Skip to content

Extendable/decorated page models #2190

@emmadesilva

Description

@emmadesilva

Support both swapping out which page model to use, and decorating existing ones. Can be done in a minor v2 release

Would be cool to be able to extend/decorate page models. For example, want to customize a bunch of stuff for MarkdownPages, maybe provide your own MakdownPage class extending the main one?

Maybe something like in Laravel?

Extending Bindings

The extend method allows the modification of resolved services. For example, when a service is resolved, you may run additional code to decorate or configure the service. The extend method accepts two arguments, the service class you're extending and a closure that should return the modified service. The closure receives the service being resolved and the container instance:

$this->app->extend(Service::class, function (Service $service, Application $app) {

return new DecoratedService($service);

});

Originally posted by @caendesilva in #1499

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions