Skip to content

Conversation

@dunglas
Copy link
Member

@dunglas dunglas commented Nov 8, 2016

Q A
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR todo

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.

*
* @return array
*/
public function getResources(): array
Copy link
Contributor

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 ?

Copy link
Member Author

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dunglas dunglas force-pushed the factory_refactoring branch from 391bdec to 25d5e0b Compare November 8, 2016 17:09

<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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad indentation

@meyerbaptiste
Copy link
Member

Nice, we need to do the same for XML!

Copy link
Member

@soyuka soyuka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

@dunglas dunglas changed the title Refactor YAML loaders [WIP} Refactor YAML and XML loaders Nov 9, 2016
@dunglas dunglas changed the title [WIP} Refactor YAML and XML loaders [WIP] Refactor YAML and XML loaders Nov 9, 2016
@dunglas dunglas force-pushed the factory_refactoring branch 2 times, most recently from 34509a7 to 834bda5 Compare November 9, 2016 21:49
@dunglas
Copy link
Member Author

dunglas commented Nov 9, 2016

Ready for review. A lot of duplicated code has been removed.

@dunglas dunglas changed the title [WIP] Refactor YAML and XML loaders Refactor and merge YAML and XML loaders Nov 9, 2016
@dunglas dunglas force-pushed the factory_refactoring branch from 34ece54 to 9b4559f Compare November 10, 2016 07:51
@dunglas
Copy link
Member Author

dunglas commented Nov 10, 2016

There is still some work to do (in other PRs):

  • Test directly the extractors instead of the the factories
  • Create abstract classes for factories (annotations and extractor) to avoid duplicating some methods like handleNotFound
  • Update the YAML format in the doc (class name as key)

@soyuka
Copy link
Member

soyuka commented Nov 10, 2016

As @teohhanhui said, I think we should keep the class key in YAML.

I won't have time to review today, maybe this we!

@dunglas
Copy link
Member Author

dunglas commented Nov 10, 2016

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ApiPlatform\Core\Metadata\Property\PropertyNameCollection;

/**
* Creates a property name collection using an extractor..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra dot.

@dunglas dunglas mentioned this pull request Nov 11, 2016
@dunglas dunglas force-pushed the factory_refactoring branch 3 times, most recently from ac00c11 to d353e6f Compare November 11, 2016 15:16
@dunglas dunglas force-pushed the factory_refactoring branch from d353e6f to 20a360e Compare November 11, 2016 15:20
@dunglas dunglas merged commit 0ecd217 into api-platform:master Nov 12, 2016
@dunglas dunglas deleted the factory_refactoring branch November 12, 2016 10:47
magarzon pushed a commit to magarzon/core that referenced this pull request Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants