-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[WIP] Kernel refactor #6459
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
[WIP] Kernel refactor #6459
Changes from 1 commit
9aaceb1
a0c49c3
892f00f
403bb06
1f1392d
adc067e
1240690
a8ea4e4
bd102c5
2eea768
f17f586
f7da1f0
76fefe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…component
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
|
||
/** | ||
* Adds services tagged kernel.content_renderer_strategy as HTTP content rendering strategies. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
class HttpRenderingStrategyPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (false === $container->hasDefinition('http_content_renderer')) { | ||
return; | ||
} | ||
|
||
$definition = $container->getDefinition('http_content_renderer'); | ||
foreach (array_keys($container->findTaggedServiceIds('kernel.content_renderer_strategy')) as $id) { | ||
$definition->addMethodCall('addStrategy', array(new Reference($id))); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<parameters> | ||
<parameter key="http_content_renderer.class">Symfony\Component\HttpKernel\HttpContentRenderer</parameter> | ||
<parameter key="http_content_renderer.strategy.default.class">Symfony\Component\HttpKernel\RenderingStrategy\DefaultRenderingStrategy</parameter> | ||
<parameter key="http_content_renderer.strategy.esi.class">Symfony\Component\HttpKernel\RenderingStrategy\EsiRenderingStrategy</parameter> | ||
<parameter key="http_content_renderer.strategy.hinclude.class">Symfony\Component\HttpKernel\RenderingStrategy\HIncludeRenderingStrategy</parameter> | ||
<parameter key="http_content_renderer.strategy.hinclude.global_template"></parameter> | ||
<parameter key="http_content_renderer.listener.router_proxy.class">Symfony\Component\HttpKernel\EventListener\RouterProxyListener</parameter> | ||
</parameters> | ||
|
||
<services> | ||
<service id="http_content_renderer" class="%http_content_renderer.class%"> | ||
<tag name="kernel.event_subscriber" /> | ||
<argument type="collection" /> | ||
<argument>%kernel.debug%</argument> | ||
</service> | ||
|
||
<service id="http_content_renderer.strategy.default" class="%http_content_renderer.strategy.default.class%"> | ||
<tag name="kernel.content_renderer_strategy" /> | ||
<argument type="service" id="http_kernel" /> | ||
<call method="setUrlGenerator"><argument type="service" id="router" /></call> | ||
</service> | ||
|
||
<service id="http_content_renderer.strategy.esi" class="%http_content_renderer.strategy.esi.class%"> | ||
<tag name="kernel.content_renderer_strategy" /> | ||
<argument type="service" id="esi" /> | ||
<argument type="service" id="http_content_renderer.strategy.default" /> | ||
<call method="setUrlGenerator"><argument type="service" id="router" /></call> | ||
</service> | ||
|
||
<service id="http_content_renderer.strategy.hinclude" class="%http_content_renderer.strategy.hinclude.class%"> | ||
<tag name="kernel.content_renderer_strategy" /> | ||
<argument type="service" id="templating" /> | ||
<argument>%http_content_renderer.strategy.hinclude.global_template%</argument> | ||
</service> | ||
|
||
<!-- FIXME: make the listener registration optional via a configuration setting? --> | ||
<service id="http_content_renderer.listener.router_proxy" class="%http_content_renderer.listener.router_proxy.class%"> | ||
<tag name="kernel.event_subscriber" /> | ||
</service> | ||
|
||
</services> | ||
</container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<route id="_proxy" pattern="/_proxy/{_controller}.{_format}" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NB: controllers could be services There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The controller name is really freeform. As mentioned by @Koc, it can be a service controller (but that's just an example as Class::method also works). |
||
</routes> |
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.
strategies could be marked as private, allowing to inline them in the container
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.
I thought about that, but because of a bug in the PHPDumper, that's not possible for hinclude. I'm working on fixing the bug so that we can use private services later on.
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.
see #6565 for the bug fix