File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,34 @@ which will inject `$container->get('config')['debug'];`
7171
7272You can use the inject annotation on setters too, they will be called at creation time and injected with the configured dependencies.
7373
74+ ### Using the AnnotatedRepositoryFactory
75+ You can register doctrine repositories and inject them using the AnnotatedRepositoryFactory as below:
76+ ``` php
77+ return [
78+ 'factories' => [
79+ ExampleRepository::class => AnnotatedRepositoryFactory::class,
80+ ],
81+ ];
82+ ```
83+
84+ The next step is to add the ` @Entity ` annotation in the repository class.
85+
86+ The ` name ` field has to be the fully qualified class name.
87+
88+ Every repository should extend ` Doctrine\ORM\EntityRepository ` .
89+ ``` php
90+ use Doctrine\ORM\EntityRepository;
91+
92+ /**
93+ * @Entity(name="App\Entity\Example")
94+ */
95+ class ExampleRepository extends EntityRepository
96+ {
97+
98+ }
99+ ```
100+
101+
74102### Using the abstract factory
75103
76104Using this approach, no service manager configuration is required. It uses the registered abstract factory to create annotated services.
Original file line number Diff line number Diff line change @@ -105,9 +105,7 @@ public function testReturnService()
105105 $ inject = new Inject (['test ' ]);
106106 $ this ->annotationReader ->method ('getMethodAnnotation ' )->willReturn ($ inject );
107107
108- $ this ->subject
109- ->method ('createAnnotationReader ' )
110- ->willReturn ($ this ->annotationReader );
108+ $ this ->subject ->method ('createAnnotationReader ' )->willReturn ($ this ->annotationReader );
111109 $ this ->subject ->method ('getReflectionClass ' )->willReturn ($ refClass );
112110
113111 $ service = $ this ->subject ->__invoke ($ this ->container , $ requestedName );
You can’t perform that action at this time.
0 commit comments