You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The next step is to add the `@Entity` annotation in the repository class.
91
+
The next step is to add the `#[Entity]` annotation in the repository class.
95
92
96
93
The `name` field has to be the fully qualified class name.
97
94
98
95
Every repository should extend `Doctrine\ORM\EntityRepository`.
99
96
```php
97
+
use Api\App\Entity\Example;
100
98
use Doctrine\ORM\EntityRepository;
101
-
use Dot\AnnotatedServices\Annotation\Entity;
99
+
use Dot\AnnotatedServices\Attribute\Entity;
102
100
103
-
/**
104
-
* @Entity(name="App\Entity\Example")
105
-
*/
101
+
#[Entity(name: Example::class)]
106
102
class ExampleRepository extends EntityRepository
107
103
{
108
-
109
-
}
110
-
```
111
-
112
-
113
-
### Using the abstract factory
114
-
115
-
Using this approach, no service manager configuration is required. It uses the registered abstract factory to create annotated services.
116
-
117
-
In order to tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation.
118
-
```php
119
-
use Dot\AnnotatedServices\Annotation\Service;
120
-
121
-
/*
122
-
* @Service
123
-
*/
124
-
class ServiceClass
125
-
{
126
-
// configure injections as described in the previous section
127
-
}
128
-
```
129
-
130
-
And that's it, you don't need to configure the service manager with this class, creation will happen automatically.
131
-
132
-
133
-
## Cache annotations
134
-
135
-
This package is built on top of `doctrine/annotation` and `doctrine/cache`.
136
-
In order to cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver. See [Cache Drivers](https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache) for available implementations offered by doctrine.
137
-
138
-
Below, we give an example, as defined in our frontend and admin starter applications
0 commit comments