-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[FrameworkBundle] Allow using a ContainerConfigurator in MicroKernelTrait::configureContainer() #34873
Merged
The head ref may contain hidden characters: "\u00B5kconfigurator"
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicolas-grekas
force-pushed
the
µkconfigurator
branch
from
December 7, 2019 16:02
f9d7a9c
to
b690a6d
Compare
Taluu
approved these changes
Dec 8, 2019
nicolas-grekas
force-pushed
the
µkconfigurator
branch
2 times, most recently
from
December 8, 2019 13:34
d6e4d6d
to
e3c9889
Compare
nicolas-grekas
force-pushed
the
µkconfigurator
branch
from
December 8, 2019 16:03
e3c9889
to
fb2c385
Compare
vudaltsov
reviewed
Dec 8, 2019
vudaltsov
approved these changes
Dec 8, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great alternative to my deprecations! Learned a lot, thanx!
nicolas-grekas
force-pushed
the
µkconfigurator
branch
2 times, most recently
from
December 11, 2019 10:47
0334df3
to
0069b92
Compare
…rait::configureContainer()
nicolas-grekas
force-pushed
the
µkconfigurator
branch
from
December 13, 2019 13:10
0069b92
to
cf45eec
Compare
nicolas-grekas
added a commit
that referenced
this pull request
Dec 13, 2019
…in MicroKernelTrait::configureContainer() (nicolas-grekas) This PR was merged into the 5.1-dev branch. Discussion ---------- [FrameworkBundle] Allow using a ContainerConfigurator in MicroKernelTrait::configureContainer() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This PR is a continuation of #32937 (it reverts some parts of it that are not needed anymore). It builds on #34872 for now. This PR allows using the PHP-DSL natively in our `Kernel::configureContainer()` methods. It allows the same in our `Kernel::configureRoutes()` methods. Both signatures are handled gracefully with no deprecations to let existing code in peace: - `protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader);` - `protected function configureContainer(ContainerConfigurator $c);` (a loader is always passed as 2nd arg to ease FC) Same for routes: - `protected function configureRoutes(RoutingConfigurator $routes);` - `protected function configureRoutes(RouteCollectionBuilder $routes);` (this one is deprecated because `RouteCollectionBuilder` is deprecated) Here is my working `src/Kernel.php` after this change: ```php class Kernel extends BaseKernel { use MicroKernelTrait; protected function configureContainer(ContainerConfigurator $container): void { $container->import('../config/{packages}/*.yaml'); $container->import('../config/{packages}/'.$this->environment.'/*.yaml'); $container->import('../config/services.yaml'); $container->import('../config/{services}_'.$this->environment.'.yaml'); } protected function configureRoutes(RoutingConfigurator $routes): void { $routes->import('../config/{routes}/'.$this->environment.'/*.yaml'); $routes->import('../config/{routes}/*.yaml'); $routes->import('../config/routes.yaml'); } } ``` Commits ------- cf45eec [FrameworkBundle] Allow using a ContainerConfigurator in MicroKernelTrait::configureContainer()
nicolas-grekas
added a commit
that referenced
this pull request
Dec 17, 2019
… of controllers and service factories (nicolas-grekas) This PR was merged into the 5.1-dev branch. Discussion ---------- [FrameworkBundle] Allow using the kernel as a registry of controllers and service factories | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #28992, fix #29997 | License | MIT | Doc PR | - This PR builds on #34873 and #34872 and allows using the `Kernel` as a registry of autowired controllers and service factories. The `ContainerConfigurator` passed to `configureContainer()` defaults to declaring autowired and autoconfigured services. TL;DR: Silex is back but in a much more powerful way \o/ Here is a Kernel that just works and displays `Hello App\Foo` on the `/` route: ```php class Kernel extends BaseKernel { use MicroKernelTrait; protected function configureContainer(ContainerConfigurator $container): void { $container->services() ->load('App\\', '../src') ->set(Foo::class) ->factory([$this, 'createFoo']); } public function createFoo(Bar $bar) { return new Foo($bar); } protected function configureRoutes(RoutingConfigurator $routes): void { $routes->add('home', '/')->controller([$this, 'helloAction']); } public function helloAction(Foo $foo) { return new Response('Hello '.get_class($foo)); } } ``` Commits ------- 9c9b99c [FrameworkBundle] Allow using the kernel as a registry of controllers and service factories
Merged
4 tasks
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a continuation of #32937 (it reverts some parts of it that are not needed anymore). It builds on #34872 for now.
This PR allows using the PHP-DSL natively in our
Kernel::configureContainer()
methods.It allows the same in our
Kernel::configureRoutes()
methods.Both signatures are handled gracefully with no deprecations to let existing code in peace:
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader);
protected function configureContainer(ContainerConfigurator $c);
(a loader is always passed as 2nd arg to ease FC)Same for routes:
protected function configureRoutes(RoutingConfigurator $routes);
protected function configureRoutes(RouteCollectionBuilder $routes);
(this one is deprecated becauseRouteCollectionBuilder
is deprecated)Here is my working
src/Kernel.php
after this change: