8000 Re-adding the ability to add a resource to the RouteCollectionBuilder by weaverryan · Pull Request #16361 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Re-adding the ability to add a resource to the RouteCollectionBuilder #16361

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
Nov 5, 2015

Conversation

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

At the end of #15778, I removed the ability to add a resource to the RouteCollectionBuilder. But, this is needed (at least internally): if you import, the returned RouteCollection may have resources, which need to be brought forward into the new RouteCollectionBuilder (the code in import() to do this already exists, but is calling an undefined addResource() method).

This adds the test with minimal code to fix.

P.S. Fabien told me to remove addResource originally... so isn't this kind of his fault?

*
* @return $this
*/
private function addResource(ResourceInterface $resource)
Copy link
Member

Choose a reason for hiding this comment

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

private methods should come after public ones.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, shouldn't this method be public? Otherwise I fail to see how $resources should ever be changed.

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 can be private. As odd as it sees, since this method is being called from inside RouteCollectionBuilder (even though it's not being called on $this, but another object), it is legal to call a private method. This is done in Silex in several places. However, I would be quite happy if this were public. I think (but don't really know) that people may eventually ask for this method if it's not present.

Copy link
Member Author

Choose a reason for hiding this comment

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

tl;dr This code actually works. But maybe we should make it public :)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I missed that call :)

Copy link
Member

Choose a reason for hiding this comment

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

private is fine

@fabpot
Copy link
Member
fabpot commented Nov 4, 2015

Can you rebase?

We need this because when you import a RouteCollection and this has a resource
on it, we need to pass that resource forward to the RouteCollectionBuilder
@weaverryan
Copy link
Member Author

Rebased! And I just realized I had originally pushed this branch to symfony/symfony - not my fork. If you don't, I'll delete that after the merge.

@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member
fabpot commented Nov 5, 2015

Thank you @weaverryan.

@fabpot fabpot merged commit 3b67daa into 2.8 Nov 5, 2015
fabpot added a commit that referenced this pull request Nov 5, 2015
…tionBuilder (weaverryan)

This PR was merged into the 2.8 branch.

Discussion
----------

Re-adding the ability to add a resource to the RouteCollectionBuilder

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

At the end of #15778, I removed the ability to add a resource to the RouteCollectionBuilder. But, this is needed (at least internally): if you import, the returned RouteCollection may have resources, which need to be brought forward into the new RouteCollectionBuilder (the code in `import()` to do this already exists, but is calling an undefined `addResource()` method).

This adds the test with minimal code to fix.

P.S. Fabien told me to remove `addResource` originally... so isn't this *kind of* his fault?

Commits
-------

3b67daa Re-adding the ability to add a resource to the RouteCollectionBuilder
@weaverryan weaverryan deleted the route_builder_fix branch November 5, 2015 20:59
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.

5 participants
0