Skip to content

Commit

Permalink
Add information for the delegator factory before 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tux-rampage committed Dec 16, 2019
1 parent 46d0e67 commit 658bcb1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/book/cookbook/aot-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,30 @@ class ConfigProvider
}
}
```
> ### Custom delegator factory (before version 3.2)
>
> The `Zend\Di\GeneratedInjectorDelegator` class is available since version 3.2. For
> prior versions of zend-di, a custom delegator factory must be provided.
>
> ```php
> namespace AppAoT;
>
> use AppAoT\Generated\GeneratedInjector;
> use Interop\Container\ContainerInterface;
> use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
>
> class GeneratedInjectorDelegator implements DelegatorFactoryInterface
> {
> public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
> {
> $injector = $callback();
>
> if (class_exists(GeneratedInjector::class)) {
> return new GeneratedInjector($injector);
> }
>
> return $injector;
> }
> }
> ```

0 comments on commit 658bcb1

Please sign in to comment.