Skip to content

[Config][Routing] Fix delegating to PSR-4 loader from subdirectory #47953

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
merged 1 commit into from
Oct 23, 2022

Conversation

derrabus
Copy link
Member

Q A
Branch? 6.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets #47943 (comment)
License MIT
Doc PR N/A

@carsonbot carsonbot changed the title Fix delegating to PSR-4 loader from subdirectory [Config][Routing] Fix delegating to PSR-4 loader from subdirectory Oct 22, 2022
@carsonbot carsonbot added this to the 6.2 milestone Oct 22, 2022
@derrabus derrabus force-pushed the bugfix/psr4-nested-dir branch from 0f81d7a to 14b9197 Compare October 22, 2022 13:29
@fabpot fabpot force-pushed the bugfix/psr4-nested-dir branch from 14b9197 to ccab500 Compare October 23, 2022 09:43
private function loadFromDirectory(string $directory, string $psr4Prefix): RouteCollection
{
$collection = new RouteCollection();
$collection->addResource(new DirectoryResource($directory, '/\.php$/'));
Copy link
Member

Choose a reason for hiding this comment

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

This was missing

private function loadFromDirectory(string $directory, string $psr4Prefix): RouteCollection
{
$collection = new RouteCollection();
$collection->addResource(new DirectoryResource($directory, '/\.php$/'));
$files = iterator_to_array(new \RecursiveIteratorIterator(
Copy link
Member

Choose a reason for hiding this comment

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

I've copy/pasted the logic from the annotation directory loader to keep the same file order. If not, the routes won't be registered in the same order and that could be a BC break.
I haven't shared the logic between the classes as I supposed that we will deprecate the annotation loader soon enough.

@fabpot fabpot force-pushed the bugfix/psr4-nested-dir branch from ccab500 to c1f0ccb Compare October 23, 2022 09:45
@fabpot
Copy link
Member

fabpot commented Oct 23, 2022

Thank you @derrabus.

@fabpot fabpot merged commit fb508d5 into symfony:6.2 Oct 23, 2022
@derrabus derrabus deleted the bugfix/psr4-nested-dir branch October 23, 2022 10:07
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.

3 participants