Permalink
Browse files

renamed some classes and Twig functions to more descriptive names (re…

…fs #6871)

HttpContentRenderer has been renamed to FragmentHandler.
The RendererStrategy subnamespace has been renamed to Fragment.
The strategy classes now have Fragment in their names.
ProxyRouterListener has been renamed to FragmentListener
The router_proxy configuration entry has been renamed to fragments.
  • Loading branch information...
1 parent 613bbbe commit 9ce3d974b90cdb7872971411280910f7e923c484 @fabpot fabpot committed Jan 31, 2013
View
@@ -4,12 +4,11 @@ CHANGELOG
2.2.0
-----
- * added Symfony\Component\HttpKernel\EventListener\RouterProxyListener
+ * added Symfony\Component\HttpKernel\EventListener\FragmentListener
* added Symfony\Component\HttpKernel\UriSigner
- * added Symfony\Component\HttpKernel\HttpContentRenderer and rendering strategies (in Symfony\Component\HttpKernel\RenderingStrategy)
- * added Symfony\Component\HttpKernel\EventListener\RouterProxyListener
+ * added Symfony\Component\HttpKernel\FragmentRenderer and rendering strategies (in Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface)
* added Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel
- * added ControllerReference to create reference of Controllers (used in the HttpContentRenderer class)
+ * added ControllerReference to create reference of Controllers (used in the FragmentRenderer class)
* [BC BREAK] renamed TimeDataCollector::getTotalTime() to
TimeDataCollector::getDuration()
* updated the MemoryDataCollector to include the memory used in the
@@ -20,8 +20,8 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
- * @see Symfony\Component\HttpKernel\HttpContentRenderer
- * @see Symfony\Component\HttpKernel\RenderingStrategy\RenderingStrategyInterface
+ * @see Symfony\Component\HttpKernel\FragmentRenderer
+ * @see Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface
*/
class ControllerReference
{
@@ -20,32 +20,35 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
- * Proxies URIs when the current route name is "_proxy".
+ * Handles content fragments represented by special URIs.
+ *
+ * All URL paths starting with /_fragment are handled as
+ * content fragments by this listener.
*
* If the request does not come from a trusted IP, it throws an
* AccessDeniedHttpException exception.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class RouterProxyListener implements EventSubscriberInterface
+class FragmentListener implements EventSubscriberInterface
{
private $signer;
- private $proxyPath;
+ private $fragmentPath;
/**
* Constructor.
*
- * @param UriSigner $signer A UriSigner instance
- * @param string $proxyPath The path that triggers this listener
+ * @param UriSigner $signer A UriSigner instance
+ * @param string $fragmentPath The path that triggers this listener
*/
- public function __construct(UriSigner $signer, $proxyPath = '/_proxy')
+ public function __construct(UriSigner $signer, $fragmentPath = '/_fragment')
{
$this->signer = $signer;
- $this->proxyPath = $proxyPath;
+ $this->fragmentPath = $fragmentPath;
}
/**
- * Fixes request attributes when the route is '_proxy'.
+ * Fixes request attributes when the path is '/_fragment'.
*
* @param GetResponseEvent $event A GetResponseEvent instance
*
@@ -55,7 +58,7 @@ public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
- if ($this->proxyPath !== rawurldecode($request->getPathInfo())) {
+ if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) {
return;
}
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel\RenderingStrategy;
+namespace Symfony\Component\HttpKernel\Fragment;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -21,32 +21,31 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class EsiRenderingStrategy extends ProxyAwareRenderingStrategy
+class EsiFragmentRenderer extends RoutableFragmentRenderer
{
private $esi;
- private $defaultStrategy;
+ private $inlineStrategy;
/**
* Constructor.
*
* The "fallback" strategy when ESI is not available should always be an
- * instance of DefaultRenderingStrategy (or a class you are using for the
- * default strategy).
+ * instance of InlineFragmentRenderer.
*
- * @param Esi $esi An Esi instance
- * @param RenderingStrategyInterface $defaultStrategy The default strategy to use when ESI is not supported
+ * @param Esi $esi An Esi instance
+ * @param InlineFragmentRenderer $inlineStrategy The inline strategy to use when ESI is not supported
*/
- public function __construct(Esi $esi, RenderingStrategyInterface $defaultStrategy)
+ public function __construct(Esi $esi, InlineFragmentRenderer $inlineStrategy)
{
$this->esi = $esi;
- $this->defaultStrategy = $defaultStrategy;
+ $this->inlineStrategy = $inlineStrategy;
}
/**
* {@inheritdoc}
*
* Note that if the current Request has no ESI capability, this method
- * falls back to use the default rendering strategy.
+ * falls back to use the inline rendering strategy.
*
* Additional available options:
*
@@ -58,16 +57,16 @@ public function __construct(Esi $esi, RenderingStrategyInterface $defaultStrateg
public function render($uri, Request $request, array $options = array())
{
if (!$this->esi->hasSurrogateEsiCapability($request)) {
- return $this->defaultStrategy->render($uri, $request, $options);
+ return $this->inlineStrategy->render($uri, $request, $options);
}
if ($uri instanceof ControllerReference) {
- $uri = $this->generateProxyUri($uri, $request);
+ $uri = $this->generateFragmentUri($uri, $request);
}
$alt = isset($options['alt']) ? $options['alt'] : null;
if ($alt instanceof ControllerReference) {
- $alt = $this->generateProxyUri($alt, $request);
+ $alt = $this->generateFragmentUri($alt, $request);
}
$tag = $this->esi->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : '');
@@ -9,58 +9,57 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel;
+namespace Symfony\Component\HttpKernel\Fragment;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
+use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
-use Symfony\Component\HttpKernel\RenderingStrategy\RenderingStrategyInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
- * Renders a URI using different strategies.
+ * Renders a URI that represents a resource fragment.
*
- * 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.
+ * This class handles the rendering of resource fragments that are included into
+ * a main resource. The handling of the rendering is managed by specialized renderers.
*
* @author Fabien Potencier <fabien@symfony.com>
*
- * @see RenderingStrategyInterface
+ * @see FragmentRendererInterface
*/
-class HttpContentRenderer implements EventSubscriberInterface
+class FragmentHandler implements EventSubscriberInterface
{
private $debug;
- private $strategies;
+ private $renderers;
private $requests;
/**
* Constructor.
*
- * @param RenderingStrategyInterface[] $strategies An array of RenderingStrategyInterface instances
- * @param Boolean $debug Whether the debug mode is enabled or not
+ * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances
+ * @param Boolean $debug Whether the debug mode is enabled or not
*/
- public function __construct(array $strategies = array(), $debug = false)
+ public function __construct(array $renderers = array(), $debug = false)
{
- $this->strategies = array();
- foreach ($strategies as $strategy) {
- $this->addStrategy($strategy);
+ $this->renderers = array();
+ foreach ($renderers as $renderer) {
+ $this->addRenderer($renderer);
}
$this->debug = $debug;
$this->requests = array();
}
/**
- * Adds a rendering strategy.
+ * Adds a renderer.
*
- * @param RenderingStrategyInterface $strategy A RenderingStrategyInterface instance
+ * @param FragmentRendererInterface $strategy A FragmentRendererInterface instance
*/
- public function addStrategy(RenderingStrategyInterface $strategy)
+ public function addRenderer(FragmentRendererInterface $renderer)
{
- $this->strategies[$strategy->getName()] = $strategy;
+ $this->renderers[$renderer->getName()] = $renderer;
}
/**
@@ -91,25 +90,25 @@ public function onKernelResponse(FilterResponseEvent $event)
* * ignore_errors: true to return an empty string in case of an error
*
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
- * @param string $strategy The strategy to use for the rendering
+ * @param string $renderer The renderer name
* @param array $options An array of options
*
* @return string|null The Response content or null when the Response is streamed
*
- * @throws \InvalidArgumentException when the strategy does not exist
+ * @throws \InvalidArgumentException when the renderer does not exist
* @throws \RuntimeException when the Response is not successful
*/
- public function render($uri, $strategy = 'default', array $options = array())
+ public function render($uri, $renderer = 'inline', array $options = array())
{
if (!isset($options['ignore_errors'])) {
$options['ignore_errors'] = !$this->debug;
}
- if (!isset($this->strategies[$strategy])) {
- throw new \InvalidArgumentException(sprintf('The "%s" rendering strategy does not exist.', $strategy));
+ if (!isset($this->renderers[$renderer])) {
+ throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer));
}
- return $this->deliver($this->strategies[$strategy]->render($uri, $this->requests[0], $options));
+ return $this->deliver($this->renderers[$renderer]->render($uri, $this->requests[0], $options));
}
/**
@@ -148,26 +147,26 @@ public static function getSubscribedEvents()
// to be removed in 2.3
public function fixOptions(array $options)
{
- // support for the standalone option is @deprecated in 2.2 and replaced with the strategy option
+ // support for the standalone option is @deprecated in 2.2 and replaced with the renderer option
if (isset($options['standalone'])) {
- trigger_error('The "standalone" option is deprecated in version 2.2 and replaced with the "strategy" option.', E_USER_DEPRECATED);
+ trigger_error('The "standalone" option is deprecated in version 2.2 and replaced with the "renderer" option.', E_USER_DEPRECATED);
// support for the true value is @deprecated in 2.2, will be removed in 2.3
if (true === $options['standalone']) {
trigger_error('The "true" value for the "standalone" option is deprecated in version 2.2 and replaced with the "esi" value.', E_USER_DEPRECATED);
$options['standalone'] = 'esi';
} elseif (false === $options['standalone']) {
- trigger_error('The "false" value for the "standalone" option is deprecated in version 2.2 and replaced with the "default" value.', E_USER_DEPRECATED);
+ trigger_error('The "false" value for the "standalone" option is deprecated in version 2.2 and replaced with the "inline" value.', E_USER_DEPRECATED);
- $options['standalone'] = 'default';
+ $options['standalone'] = 'inline';
} elseif ('js' === $options['standalone']) {
trigger_error('The "js" value for the "standalone" option is deprecated in version 2.2 and replaced with the "hinclude" value.', E_USER_DEPRECATED);
$options['standalone'] = 'hinclude';
}
- $options['strategy'] = $options['standalone'];
+ $options['renderer'] = $options['standalone'];
unset($options['standalone']);
}
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel\RenderingStrategy;
+namespace Symfony\Component\HttpKernel\Fragment;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
@@ -19,9 +19,9 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
- * @see Symfony\Component\HttpKernel\HttpContentRenderer
+ * @see Symfony\Component\HttpKernel\FragmentRenderer
*/
-interface RenderingStrategyInterface
+interface FragmentRendererInterface
{
/**
* Renders a URI and returns the Response content.
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel\RenderingStrategy;
+namespace Symfony\Component\HttpKernel\Fragment;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -22,7 +22,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class HIncludeRenderingStrategy extends ProxyAwareRenderingStrategy
+class HIncludeFragmentRenderer extends RoutableFragmentRenderer
{
protected $templating;
@@ -61,7 +61,7 @@ public function render($uri, Request $request, array $options = array())
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
}
- $uri = $this->signer->sign($this->generateProxyUri($uri, $request));
+ $uri = $this->signer->sign($this->generateFragmentUri($uri, $request));
}
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
@@ -9,19 +9,19 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel\RenderingStrategy;
+namespace Symfony\Component\HttpKernel\Fragment;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
/**
- * Implements the default rendering strategy where the Request is rendered by the current HTTP kernel.
+ * Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class DefaultRenderingStrategy extends ProxyAwareRenderingStrategy
+class InlineFragmentRenderer extends RoutableFragmentRenderer
{
private $kernel;
@@ -45,7 +45,7 @@ public function __construct(HttpKernelInterface $kernel)
public function render($uri, Request $request, array $options = array())
{
if ($uri instanceof ControllerReference) {
- $uri = $this->generateProxyUri($uri, $request);
+ $uri = $this->generateFragmentUri($uri, $request);
}
$subRequest = $this->createSubRequest($uri, $request);
@@ -95,6 +95,6 @@ protected function createSubRequest($uri, Request $request)
*/
public function getName()
{
- return 'default';
+ return 'inline';
}
}
Oops, something went wrong.

0 comments on commit 9ce3d97

Please sign in to comment.