-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Content renderer simplification #6829
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
Changes from all commits
b9f0e17
ad82893
3193a90
e5135f6
23f5145
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?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.listener.router_proxy.class">Symfony\Component\HttpKernel\EventListener\RouterProxyListener</parameter> | ||
</parameters> | ||
|
||
<services> | ||
<service id="http_content_renderer.listener.router_proxy" class="%http_content_renderer.listener.router_proxy.class%"> | ||
<tag name="kernel.event_subscriber" /> | ||
<argument type="service" id="uri_signer" /> | ||
<argument>%http_content_renderer.proxy_path%</argument> | ||
</service> | ||
</services> | ||
</container> |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,13 @@ | |
/** | ||
* Renders a URI using different strategies. | ||
* | ||
* This class handles sub-requests. The response content from the sub-request | ||
* is then embedded into a master request. The handling of the sub-request | ||
* is managed by rendering strategies. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
* | ||
* @see RenderingStrategyInterface | ||
*/ | ||
class HttpContentRenderer implements EventSubscriberInterface | ||
{ | ||
|
@@ -103,9 +109,7 @@ public function render($uri, $strategy = 'default', array $options = array()) | |
throw new \InvalidArgumentException(sprintf('The "%s" rendering strategy does not exist.', $strategy)); | ||
} | ||
|
||
$request = $this->requests ? $this->requests[0] : null; | ||
|
||
return $this->deliver($this->strategies[$strategy]->render($uri, $request, $options)); | ||
return $this->deliver($this->strategies[$strategy]->render($uri, $this->requests[0], $options)); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
* | ||
* @author Fabien Potencier <[email protected]> | ||
*/ | ||
class DefaultRenderingStrategy extends GeneratorAwareRenderingStrategy | ||
class DefaultRenderingStrategy extends ProxyAwareRenderingStrategy | ||
{ | ||
private $kernel; | ||
|
||
|
@@ -42,7 +42,7 @@ public function __construct(HttpKernelInterface $kernel) | |
* | ||
* * alt: an alternative URI to render in case of an error | ||
*/ | ||
public function render($uri, Request $request = null, array $options = array()) | ||
public function render($uri, Request $request, array $options = array()) | ||
{ | ||
if ($uri instanceof ControllerReference) { | ||
$uri = $this->generateProxyUri($uri, $request); | ||
|
@@ -74,21 +74,16 @@ public function render($uri, Request $request = null, array $options = array()) | |
} | ||
} | ||
|
||
protected function createSubRequest($uri, Request $request = null) | ||
protected function createSubRequest($uri, Request $request) | ||
{ | ||
if (null !== $request) { | ||
$cookies = $request->cookies->all(); | ||
$server = $request->server->all(); | ||
|
||
// the sub-request is internal | ||
$server['REMOTE_ADDR'] = '127.0.0.1'; | ||
} else { | ||
$cookies = array(); | ||
$server = array(); | ||
} | ||
$cookies = $request->cookies->all(); | ||
$server = $request->server->all(); | ||
|
||
// the sub-request is internal | ||
$server['REMOTE_ADDR'] = '127.0.0.1'; | ||
|
||
$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server); | ||
if (null !== $request && $session = $request->getSession()) { | ||
if ($session = $request->getSession()) { | ||
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 condition useful here ? 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. yes, because you can disable the session entirely in FrameworkBundle 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. Also the phpdoc says it can return null. 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. I still don't see the pb with set(null) ? 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. ok, now I see :) |
||
$subRequest->setSession($session); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
* | ||
* @author Fabien Potencier <[email protected]> | ||
*/ | ||
class EsiRenderingStrategy extends GeneratorAwareRenderingStrategy | ||
class EsiRenderingStrategy extends ProxyAwareRenderingStrategy | ||
{ | ||
private $esi; | ||
private $defaultStrategy; | ||
|
@@ -55,9 +55,9 @@ public function __construct(Esi $esi, RenderingStrategyInterface $defaultStrateg | |
* | ||
* @see Symfony\Component\HttpKernel\HttpCache\ESI | ||
*/ | ||
public function render($uri, Request $request = null, array $options = array()) | ||
public function render($uri, Request $request, array $options = array()) | ||
{ | ||
if (null === $request || !$this->esi->hasSurrogateEsiCapability($request)) { | ||
if (!$this->esi->hasSurrogateEsiCapability($request)) { | ||
return $this->defaultStrategy->render($uri, $request, $options); | ||
} | ||
|
||
|
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.
router_proxy_path ?