Skip to content

[HttpKernel] Add a ContainerControllerResolver (psr-11) #21768

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
Feb 28, 2017
Merged

[HttpKernel] Add a ContainerControllerResolver (psr-11) #21768

merged 1 commit into from
Feb 28, 2017

Conversation

ogizanagi
Copy link
Contributor

@ogizanagi ogizanagi commented Feb 26, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

Extracts the controller as service resolution from the framework bundle controller resolver in a Symfony/Component/HttpKernel/Controller/Psr11ControllerResolver, allowing you to use HttpKernel with your own psr-11 container.

}
}

return parent::createController($controller);
Copy link
Contributor

Choose a reason for hiding this comment

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

This method could be rewritten to use guard clauses, making it a lot easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made some changes. Is it better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Much better yes!


class ControllerResolverTest extends BaseControllerResolverTest
class ControllerResolverTest extends Psr11ControllerResolverTest
Copy link
Contributor

Choose a reason for hiding this comment

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

tests in this class could stay to verify it doesn't change behavior, if this happens, it would break a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests cases were simply moved in the Psr11ControllerResolverTest class and are inherited, so I think we're safe, aren't we? :)

@@ -35,39 +34,19 @@ class ControllerResolver extends BaseControllerResolver
*/
public function __construct(ContainerInterface $container, ControllerNameParser $parser, LoggerInterface $logger = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just changing the type hint and make the parser optional?

Copy link
Contributor Author

@ogizanagi ogizanagi Feb 26, 2017

Choose a reason for hiding this comment

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

Because the new class is available in the HttpKernel component, whereas this one is in the framework bundle, as well as the ControllerNameParser.
I'm fine with this class as is in the framework. :) I just think having a base ControllerResolver usable with psr-11 shipped with the component makes sense.

@nicolas-grekas nicolas-grekas added this to the 3.x milestone Feb 27, 2017
@nicolas-grekas
Copy link
Member

I'm not fan of the Psr11 prefix. What about ServiceLocatorControllerResolver? ContainerControllerResolver? ServiceControllerResolver?

@ogizanagi
Copy link
Contributor Author

Why not. What is your own preference? What do others think?

I like ServiceControllerResolver.

@stof
Copy link
Member

stof commented Feb 28, 2017

I prefer ContainerControllerResolver actually. Service alone looks a bit weird to me

@ogizanagi ogizanagi changed the title [HttpKernel] Add a Psr11ControllerResolver [HttpKernel] Add a ContainerControllerResolver (psr-11) Feb 28, 2017
@ogizanagi
Copy link
Contributor Author

Renamed to ContainerControllerResolver. That's the psr title after all :)

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

👍 (minor comment)

/**
* @param ContainerInterface $container A psr-11 container instance
* @param LoggerInterface|null $logger
*/
Copy link
Member

Choose a reason for hiding this comment

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

The docblock can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Fixed

@fabpot
Copy link
Member

fabpot commented Feb 28, 2017

Thank you @ogizanagi.

@fabpot fabpot merged commit 7bbae41 into symfony:master Feb 28, 2017
fabpot added a commit that referenced this pull request Feb 28, 2017
…) (ogizanagi)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[HttpKernel] Add a ContainerControllerResolver (psr-11)

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

Extracts the controller as service resolution from the framework bundle controller resolver in a `Symfony/Component/HttpKernel/Controller/Psr11ControllerResolver`, allowing you to use `HttpKernel` with your own psr-11 container.

Commits
-------

7bbae41 [HttpKernel] Add a ContainerControllerResolver (psr-11)
@ogizanagi ogizanagi deleted the feature/3.3/http_kernel/psr11_controller_resolver branch February 28, 2017 20:46
@nicolas-grekas nicolas-grekas modified the milestones: 3.x, 3.3 Mar 24, 2017
@fabpot fabpot mentioned this pull request May 1, 2017
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.

7 participants