-
-
Notifications
You must be signed in to change notification settings - Fork 949
Refactor and merge YAML and XML loaders #837
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
src/Metadata/YamlExtractor.php
Outdated
| * | ||
| * @return array | ||
| */ | ||
| public function getResources(): array |
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.
What do you think about splitting this methods ?
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.
It was a POC, but indeed, it's a good idea :)
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.
Done.
391bdec to
25d5e0b
Compare
|
|
||
| <service id="api_platform.metadata.resource.metadata_factory.yaml" decorates="api_platform.metadata.resource.metadata_factory" class="ApiPlatform\Core\Metadata\Resource\Factory\YamlResourceMetadataFactory" decoration-priority="40" public="false"> | ||
| <argument type="collection" /> | ||
| <argument type="service" id="api_platform.metadata.extractor.yaml" /> |
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.
Bad indentation
|
Nice, we need to do the same for XML! |
soyuka
left a comment
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.
Nice one!
34509a7 to
834bda5
Compare
|
Ready for review. A lot of duplicated code has been removed. |
34ece54 to
9b4559f
Compare
|
There is still some work to do (in other PRs):
|
|
As @teohhanhui said, I think we should keep the I won't have time to review today, maybe this we! |
|
Why? With the new implementation it's mandatory to have the class as key. It will just be duplicated data. |
| $attributes = []; | ||
| foreach ($resource->$elementName as $attribute) { | ||
| $value = isset($attribute->attribute[0]) ? $this->getAttributes($attribute, 'attribute') : (string) $attribute; | ||
| isset($attribute['name']) ? $attributes[(string) $attribute['name']] = $value : $attributes[] = $value; |
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.
See #814 (comment)
| use ApiPlatform\Core\Metadata\Property\PropertyNameCollection; | ||
|
|
||
| /** | ||
| * Creates a property name collection using an extractor.. |
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.
Extra dot.
ac00c11 to
d353e6f
Compare
d353e6f to
20a360e
Compare
Refactor and merge YAML and XML loaders
Drastically simplify the code, remove a lot of duplication and improve performances.
BC break: the class name is not the key of the definition.
Can you review this please @soyuka and @meyerbaptiste.