From 2df32494f8d741fcc2cecd55275ca8a331c73cc2 Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Fri, 18 Oct 2024 15:34:30 +0200 Subject: [PATCH] docs: add some doc for the instantiator --- docs/index.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 9a3f1aad..d4ae666b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -648,9 +648,17 @@ You can customize the instantiator in several ways: // can combine the different "modes" ->instantiateWith(Instantiator::withoutConstructor()->allowExtra()->alwaysForce()) + // use a "namedConstructor" + ->instantiateWith(Instantiator::namedConstructor("methodName")) + + // use a callable + ->instantiateWith(Instantiator::use(function(string $title): object { + return new Post($title); // ... your own logic + })) + // the instantiator is just a callable, you can provide your own - ->instantiateWith(function(array $attributes, string $class): object { - return new Post(); // ... your own logic + ->instantiateWith(function(string $title): object { + return new Post($title); // ... your own logic }) ;