-
-
Notifications
You must be signed in to change notification settings - Fork 929
#79 custom identifier #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -97,6 +105,7 @@ class AttributeMetadata implements AttributeMetadataInterface | |||
public function __construct($name) | |||
{ | |||
$this->name = $name; | |||
$this->isIdentifier = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't it be part of the constructor (with a default value) ? Even if it's not the case right now, I'd expect this attribute metadata to be immutable as much as possible.
Another question is posed by these Dev. {
"@context": "http://schema.org",
"@type": "Country",
"@id": "/countries/en",
"name": "Angleterre"
} I think it's an error, @id point to an IRI an must be present : OK IMO, don't treat the attribute id differently than other attribute and user can set with a "@group" if he want to be serialized or not. |
I think the internal (database) id should never be exposed directly and must be replaced by the public external identifier (the IRI). It's the motivation behind the current behavior. |
About your use case: the JSON-LD should never know anything from server internals. It doesn't have to deal with the internal database id, it's the server responsibility. |
Yes you're right but in my sample (and actually in my dev) I need to be able to set the identifier because it's not automatically determinate by the server. The issue is the normalizer must have option to not ignore the identifier if it's needed on POST / PUT request. Actually I set ignoring identifier on JsonLd/Serializer/ItemNormalizer.php but on denormalizer so we can set it on POST / PUT request. |
@MLKiiwy It's maybe because you've design issues in your code. IMHO the Domain Objects (in that case the API output/input) mustn't care about the storage layer. The |
Still in WIP. I add two tests : custom_identifier.feature and custom_writable_identifier.feature I think it cover all the needs, what do you think ? |
# The first commit's message is: 79-custom-identifier : add identify class identifier from doctrine # This is the 2nd commit message: #79-custom-identifier : wip # This is the 3rd commit message: #79-custom-identifier : wip # This is the 4th commit message: #79-custom-identifier : add : full tests cases # This is the 5th commit message: #79-custom-identifier : fix : config # This is the 6th commit message: #79-custom-identifier : wip # This is the 7th commit message: #79-custom-identifier : wip
@dunglas here is my last version ! |
Actually we identify the entity identifier from Doctrine Identifier. | ||
We don't support entity resource with multiple identifier. | ||
|
||
The entity identifier is never returned like other properties : it's a part of the URI contained in @id field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ca you put @id
into backticks ``` and replace URI by IRI for coherence?
Thank you @MLKiiwy |
Remove deps added by error
For issue : #79
Add support of custom identifier for doctrine (other than Id)
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)