Skip to content

Comments

Prefix root resource's route_prefix to sub-resources#2294

Merged
dunglas merged 1 commit intoapi-platform:2.3from
silverbackdan:patch/subresource-route-prefix
Nov 1, 2018
Merged

Prefix root resource's route_prefix to sub-resources#2294
dunglas merged 1 commit intoapi-platform:2.3from
silverbackdan:patch/subresource-route-prefix

Conversation

@silverbackdan
Copy link
Contributor

I think this is a bug, sorry if it isn't. This will make a sub-resource have the same route_prefix as the root resource. Is this the expected behaviour?

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

$operation['operation_name']
);

$prefix = trim(trim($rootResourceMetadata->getAttribute('route_prefix', '')), '/');
Copy link
Member

Choose a reason for hiding this comment

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

we don't need the first trim imo

Copy link
Contributor Author

@silverbackdan silverbackdan Oct 30, 2018

Choose a reason for hiding this comment

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

This is lifted straight from here https://github.com/api-platform/core/blob/master/src/Bridge/Symfony/Routing/ApiLoader.php#L204 - do you think I should adjust both or is there another reason why you think both trims aren't needed here? Also would you mind clarifying if you mean the inner or outer trim when you say 'first'?

Copy link
Contributor

Choose a reason for hiding this comment

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

Better keep both, but I think that the inner one is less usefull.
Pretty sure that some users use "route_prefix"="/foo" or "route_prefix"="foo/" and setting "route_prefix"="/" would be strange but would not have impact at least.

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.

Def. a bug, nice catch

@silverbackdan
Copy link
Contributor Author

Thanks both @soyuka and @antograssiot
This will save a lot of extra config for me 😄

@dunglas dunglas merged commit 3b41b80 into api-platform:2.3 Nov 1, 2018
@dunglas
Copy link
Member

dunglas commented Nov 1, 2018

Thanks @silverbackdan!

@silverbackdan silverbackdan deleted the patch/subresource-route-prefix branch April 3, 2020 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants