-
-
Notifications
You must be signed in to change notification settings - Fork 929
Description
Custom identifiers, in a non-Doctrine context.
Since #125, we have potential extension points for loading and defining what represents the identifier in a class.
Something that would have been great, is having a simple property annotation allowing to define which property is the identifier in the class.
Regarding:
The possibility to add an annotation to set our custom idenfier manually without doctrine was removed from this PR and moved in another future PR. Because it imply other changes ... in DataProvider fro example (cant use Doctrine getReference ... DataProvider is really doctrine linked)
I'm not sure I understand the issue, because custom identifiers are not only something needed in the Doctrine context.
Custom (identifier) loaders
On a second hand, currently, we cannot easily add our own loader in the LoaderChain
, except using a compiler pass. Is it a sufficient workflow or should we expose more convenient ways to extend this part ?
ValueObject & no identifier
Last but not the least: as stated in #202 (comment):
Also, we should be able to expose resources which do not have an ID. This would be the case for value objects, which may be used for some custom operations.
It's currently impossible, as we get the following exception:
The class "AppBundle\ValueObject\Foo" has no identifier.
A real identifier property does not make any sense for such objects (meant to be used to submit custom payloads with the POST http verb for instance).
But if we really need to have an identifier in ClassMetadata, what about using the same annotation as mentioned above, but on the class, with a value
property (default: classname) ?