Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Moves default and user-configured overridden bundle path registration to a CompilerPass #30360

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

Closed
wants to merge 8 commits into from

Conversation

alterphp
Copy link

@alterphp alterphp commented Feb 23, 2019

Q A
Branch? 4.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #30359
License MIT

If #30359 is indeed considered as bug or problem, this PR is a solution to solve it.

TwigBundle default overriden bundle paths are defined too early in the bundle definition process. They are now configured in a CompilerPass that allows 3rd party bundles to override any Twig namespace and let the user have its own project overrides.

According to @yceruto request, I also moved the user-configured paths to the compiler pass.

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

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

Are you sure this is only for 4.2 and no bugfix for 3.4 branch which is also maintained?

}
}

private function normalizeBundleName($name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private function normalizeBundleName($name)
private function normalizeBundleName(string $name): string

but substr() could also return false... what do do here then @nicolas-grekas ?

Copy link
Author

@alterphp alterphp Feb 23, 2019

Choose a reason for hiding this comment

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

@OskarStark @nicolas-grekas I just copied the method from TwigExtension. Then I don't like copying the logic... Any suggestion on this ?

@OskarStark
Copy link
Contributor

And btw there are two typos in the PR title:

- Moves default overriden bnudle path registration to a CompilerPass
+ Moves default overridden bundle path registration to a CompilerPass

@alterphp
Copy link
Author

alterphp commented Feb 23, 2019

Are you sure this is only for 4.2 and no bugfix for 3.4 branch which is also maintained?

@OskarStark At least 4.x and master. For 3.4, I have to check. Should i list target branches in the head Q/A section ?

@alterphp alterphp changed the title Moves default overriden bnudle path registration to a CompilerPass Moves default overridden bundle path registration to a CompilerPass Feb 23, 2019
@alterphp alterphp changed the title Moves default overridden bundle path registration to a CompilerPass Moves default and user-configured overridden bundle path registration to a CompilerPass Feb 25, 2019
@alterphp
Copy link
Author

alterphp commented Mar 5, 2019

@yceruto @OskarStark Any update on this one ?

$bundleHierarchy[$name][] = $defaultOverrideBundlePath;
}
$container->addResource(new FileExistenceResource($defaultOverrideBundlePath));

if (file_exists($dir = $bundle['path'].'/Resources/views')) {
Copy link
Member

Choose a reason for hiding this comment

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

Hi @alterphp, re-thinking this in another way... instead, what about moving this registration (as late as possible) into the compiler pass and call to addPath always?

I mean, G1 and G2 as before in the same place, and only G3 into the compiler pass, thus other bundles would addPath before G3 keeping the priority/order and also less changes than now.

Copy link
Author

Choose a reason for hiding this comment

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

It took me some minutes to understand ... and it sounds far better than what I have done until now. I'm gonna take the time to refactor this.

Thanks for review !

@yceruto
Copy link
Member

yceruto commented Mar 5, 2019

I also think this is more a new feature (master branch) rather than a bugfix, because you're improving the paths registration process to allow bundles "easily" insert new "override" paths for other bundles and actually you've altenatives #30360 (comment)

@alterphp
Copy link
Author

Closed in favor or #30527

@alterphp alterphp closed this Mar 11, 2019
@alterphp alterphp deleted the fix/30359 branch March 11, 2019 21:50
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.

6 participants