Skip to content

fix #1479 allow to override SubresourceOperations through metadata #1483

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

Merged

Conversation

soyuka
Copy link
Member

@soyuka soyuka commented Nov 8, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1479
License MIT
Doc PR TODO

Also backported #1472 to subresources

@@ -87,6 +87,9 @@ public function load($data, $type = null): RouteCollection

if (null !== $collectionOperations = $resourceMetadata->getCollectionOperations()) {
foreach ($collectionOperations as $operationName => $operation) {
if ('subresource' === substr($operationName, -11)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Either this or we add a SubresourceOperations in the resource metadata declarations. Lmk.

Copy link
Contributor

@iCodr8 iCodr8 Nov 8, 2017

Choose a reason for hiding this comment

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

I think subresourceOperations would make more sense.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thank you!

@soyuka soyuka force-pushed the fix-subresource-override-operation branch from 3a8c6c7 to 683d6fc Compare November 8, 2017 15:53
@soyuka soyuka changed the title fix #1479 fix #1479 allow to override SubresourceOperations through metadata Nov 8, 2017
/**
* Returns a new instance with the given subresource operations.
*
* @param array $subresourceOperations
Copy link
Member

Choose a reason for hiding this comment

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

You can remove those annotations (it's already documented by typehints).

Copy link
Member Author

Choose a reason for hiding this comment

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

copy pasted, why don't we remove the other ones then?

@@ -193,6 +220,21 @@ public function getItemOperationAttribute(string $operationName = null, string $
}

/**
* Gets a subresource operation attribute, optionally fallback to a resource attribute.
*
* @param string|null $operationName
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@soyuka soyuka force-pushed the fix-subresource-override-operation branch 2 times, most recently from 97ef0bc to 94a420a Compare November 15, 2017 17:10
Copy link
Member

@meyerbaptiste meyerbaptiste left a comment

Choose a reason for hiding this comment

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

Minor change

'',
[],
['GET']
] + ($operation['defaults'] ?? []),
Copy link
Member

Choose a reason for hiding this comment

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

All parenthesis are useless here.

@soyuka soyuka force-pushed the fix-subresource-override-operation branch from 94a420a to 17c321f Compare November 16, 2017 13:40
@meyerbaptiste meyerbaptiste merged commit 091865f into api-platform:master Nov 17, 2017
@meyerbaptiste
Copy link
Member

Thanks @soyuka

@soyuka soyuka deleted the fix-subresource-override-operation branch November 22, 2017 15:49
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
…ride-operation

fix api-platform#1479 allow to override SubresourceOperations through metadata
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