Skip to content

Commit

Permalink
changed the template name format
Browse files Browse the repository at this point in the history
Before

bundle:section:template.format.renderer

After

bundle:section:template.renderer.format

Notice that both the renderer and the format are mandatory.
  • Loading branch information
fabpot committed Jan 15, 2011
1 parent 75c6f47 commit a365ab2
Show file tree
Hide file tree
Showing 79 changed files with 81 additions and 81 deletions.
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
{% extends 'WebProfilerBundle:Profiler:layout.twig.html' %}

{% block toolbar %}
<img style="margin: 0 5px 0 10px; vertical-align: middle; height: 24px" width="24" height="24" alt="Database" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAASxJREFUeNrsV00KhCAYzaGDzLZbONcIghadoDZtiqJNbVq0Ctq06xjNCTrDnKMfGoVpsFBRqNz4QD7NR77vmZ8E1nU1VOJhKIYWoAUoF2CSAwBAf9E6L3JAHn1ADrquu6Qo2LYNWAJ2DizLYjiOg8lnO9HTnKAKwGjbFl7hhOu6/G9gnud/9DzvFieYAjDquoa3noJpmqhRuQDf99+8l5RlCWV40gKKouBuhSyPKWAcR2qMooibWZZlUIYn7UAcx0KZifKkHcjznJpZGIa7BVk8Fl/YgSAIoEhGLJ6wA4iQ3H0Md9dxVVXpUcCxDcPwQRHg9utLzR+TMmmqUCVMyIpIwrKs5/ac7IvOc7dgQ9M0KUvApZXwCHQ7YieSk9fcvQ/oHxMtQAtQLeArwABN1BHcHlpLnQAAAABJRU5ErkJggg==" />
Expand Down
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
{% extends 'WebProfilerBundle:Profiler:layout.twig.html' %}

{% block toolbar %}
<img style="margin: 0 5px 0 10px; vertical-align: middle; height: 24px" width="24" height="24" alt="Mongo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAASxJREFUeNrsV00KhCAYzaGDzLZbONcIghadoDZtiqJNbVq0Ctq06xjNCTrDnKMfGoVpsFBRqNz4QD7NR77vmZ8E1nU1VOJhKIYWoAUoF2CSAwBAf9E6L3JAHn1ADrquu6Qo2LYNWAJ2DizLYjiOg8lnO9HTnKAKwGjbFl7hhOu6/G9gnud/9DzvFieYAjDquoa3noJpmqhRuQDf99+8l5RlCWV40gKKouBuhSyPKWAcR2qMooibWZZlUIYn7UAcx0KZifKkHcjznJpZGIa7BVk8Fl/YgSAIoEhGLJ6wA4iQ3H0Md9dxVVXpUcCxDcPwQRHg9utLzR+TMmmqUCVMyIpIwrKs5/ac7IvOc7dgQ9M0KUvApZXwCHQ7YieSk9fcvQ/oHxMtQAtQLeArwABN1BHcHlpLnQAAAABJRU5ErkJggg==" />
Expand Down
Expand Up @@ -28,6 +28,6 @@ class DefaultController extends ContainerAware
*/
public function indexAction()
{
return $this->container->get('templating')->renderResponse('FrameworkBundle:Default:index.php');
return $this->container->get('templating')->renderResponse('FrameworkBundle:Default:index.twig.html');
}
}
Expand Up @@ -32,7 +32,7 @@ class ExceptionController extends ContainerAware
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function exceptionAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);

Expand All @@ -43,15 +43,16 @@ public function exceptionAction(FlattenException $exception, DebugLoggerInterfac

$code = $this->getStatusCode($exception);

$template = $this->container->get('kernel')->isDebug() ? 'exception' : 'error';
$name = $this->container->get('kernel')->isDebug() ? 'exception' : 'error';
if ($this->container->get('kernel')->isDebug() && 'html' == $format) {
$template = 'exception_full';
$name = 'exception_full';
}
$template = 'FrameworkBundle:Exception:'.$template.'.twig';
$template = 'FrameworkBundle:Exception:'.$name.'.twig.'.$format;

$templating = $this->container->get('templating');
if (!$templating->exists($template)) {
$this->container->get('request')->setRequestFormat('html');
$template = 'FrameworkBundle:Exception:'.$name.'.twig.html';
}

$response = $templating->renderResponse(
Expand Down
Expand Up @@ -193,9 +193,9 @@ protected function registerTemplatingConfiguration(array $config, ContainerBuild
}

// template paths
$dirs = array('%kernel.root_dir%/views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%');
$dirs = array('%kernel.root_dir%/views/%%bundle%%/%%controller%%/%%name%%.%%renderer%%.%%format%%');
foreach ($container->getParameter('kernel.bundle_dirs') as $dir) {
$dirs[] = $dir.'/%%bundle%%/Resources/views/%%controller%%/%%name%%%%format%%.%%renderer%%';
$dirs[] = $dir.'/%%bundle%%/Resources/views/%%controller%%/%%name%%.%%renderer%%.%%format%%';
}
$container->setParameter('templating.loader.filesystem.path', $dirs);

Expand Down
Expand Up @@ -10,7 +10,7 @@
<parameter key="controller_name_converter.class">Symfony\Bundle\FrameworkBundle\Controller\ControllerNameConverter</parameter>
<parameter key="response_listener.class">Symfony\Component\HttpKernel\ResponseListener</parameter>
<parameter key="exception_listener.class">Symfony\Component\HttpKernel\Debug\ExceptionListener</parameter>
<parameter key="exception_listener.controller">Symfony\Bundle\FrameworkBundle\Controller\ExceptionController::exceptionAction</parameter>
<parameter key="exception_listener.controller">Symfony\Bundle\FrameworkBundle\Controller\ExceptionController::showAction</parameter>
<parameter key="esi.class">Symfony\Component\HttpKernel\Cache\Esi</parameter>
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\Cache\EsiListener</parameter>
</parameters>
Expand Down

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
{% include 'FrameworkBundle:Exception:error.twig.xml' with { 'exception': exception } %}
@@ -0,0 +1 @@
{% include 'FrameworkBundle:Exception:error.twig.xml' with { 'exception': exception } %}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
{% include 'FrameworkBundle:Exception:exception.twig.xml' with { 'exception': exception } %}
@@ -0,0 +1,3 @@
/*
{% include 'FrameworkBundle:Exception:exception.twig.txt' with { 'exception': exception } %}
*/
Expand Up @@ -25,7 +25,7 @@ <h2><strong>{{ status_code }}</strong> {{ status_text }} - {{ exception.class|ab
</div>

{% for position, e in exception.toarray %}
{% include 'FrameworkBundle:Exception:traces.twig' with { 'exception': e, 'position': position, 'count': previous_count } only %}
{% include 'FrameworkBundle:Exception:traces.twig.html' with { 'exception': e, 'position': position, 'count': previous_count } only %}
{% endfor %}

{% if logger %}
Expand All @@ -38,7 +38,7 @@ <h3>
</h3>

<div id="logs" style="display: none">
{% include 'FrameworkBundle:Exception:logs.twig' with { 'logs': logger.logs } only %}
{% include 'FrameworkBundle:Exception:logs.twig.html' with { 'logs': logger.logs } only %}
</div>

</div>
Expand Down
@@ -0,0 +1,3 @@
/*
{% include 'FrameworkBundle:Exception:exception.twig.txt' with { 'exception': exception } %}
*/
@@ -0,0 +1 @@
{% include 'FrameworkBundle:Exception:exception.twig.xml' with { 'exception': exception } %}
Expand Up @@ -2,6 +2,6 @@
[message] {{ exception.message }}
{% for i, e in exception.toarray %}
[{{ i + 1 }}] {{ e.class }}: {{ e.message }}
{% include 'FrameworkBundle:Exception:traces.txt.twig' with { 'exception': e } only %}
{% include 'FrameworkBundle:Exception:traces.twig.txt' with { 'exception': e } only %}

{% endfor %}
Expand Up @@ -3,7 +3,7 @@
<error code="{{ status_code }}" message="{{ status_text }}">
{% for e in exception.toarray %}
<exception class="{{ e.class }}" message="{{ e.message }}">
{% include 'FrameworkBundle:Exception:traces.twig' with { 'exception': e } only %}
{% include 'FrameworkBundle:Exception:traces.twig.xml' with { 'exception': e } only %}
</exception>
{% endfor %}
</error>

This file was deleted.

@@ -0,0 +1,5 @@
{% extends 'FrameworkBundle:Exception:layout.twig.html' %}

{% block body %}
{% include 'FrameworkBundle:Exception:exception.twig.html' %}
{% endblock %}
Expand Up @@ -13,7 +13,7 @@ <h3>Stack Trace</h3>
<ol class="traces" id="traces_{{ position }}" style="display: {{ 0 == position ? 'block' : 'none' }}">
{% for i, trace in exception.trace %}
<li>
{% include 'FrameworkBundle:Exception:trace.twig' with { 'prefix': position, 'i': i, 'trace': trace } only %}
{% include 'FrameworkBundle:Exception:trace.twig.html' with { 'prefix': position, 'i': i, 'trace': trace } only %}
</li>
{% endfor %}
</ol>
Expand Down
@@ -1,6 +1,6 @@
{% if exception.trace|length %}
{% for trace in exception.trace %}
{% include 'FrameworkBundle:Exception:trace.txt.twig' with { 'trace': trace } only %}
{% include 'FrameworkBundle:Exception:trace.twig.txt' with { 'trace': trace } only %}

{% endfor %}
{% endif %}
@@ -1,7 +1,7 @@
<traces>
{% for trace in exception.trace %}
<trace>
{% include 'FrameworkBundle:Exception:trace.txt.twig' with { 'trace': trace } only %}
{% include 'FrameworkBundle:Exception:trace.twig.txt' with { 'trace': trace } only %}

</trace>
{% endfor %}
Expand Down
Expand Up @@ -15,7 +15,7 @@

/**
* TemplateNameParser parsers template name from the short notation
* "bundle:section:template.format.renderer" to a template name
* "bundle:section:template.renderer.format" to a template name
* and an array of options.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
Expand All @@ -34,7 +34,7 @@ public function parse($name, array $defaults = array())
{
$parts = explode(':', $name);
if (3 !== count($parts)) {
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name));
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.renderer.format").', $name));
}

$options = array_replace(
Expand All @@ -49,17 +49,14 @@ public function parse($name, array $defaults = array())
);

$elements = explode('.', $parts[2]);
if (3 === count($elements)) {
$parts[2] = $elements[0];
$options['format'] = '.'.$elements[1];
$options['renderer'] = $elements[2];
} elseif (2 === count($elements)) {
$parts[2] = $elements[0];
$options['renderer'] = $elements[1];
} else {
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name));
if (3 !== count($elements)) {
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.renderer.format").', $name));
}

$parts[2] = $elements[0];
$options['renderer'] = $elements[1];
$options['format'] = $elements[2];

return array($parts[2], $options);
}
}
Expand Up @@ -29,9 +29,9 @@ public function testParse($name, $parameters)
public function getParseTests()
{
return array(
array('BlogBundle:Post:index.php', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => ''))),
array('BlogBundle:Post:index.twig', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'twig', 'format' => ''))),
array('BlogBundle:Post:index.xml.php', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => '.xml'))),
array('BlogBundle:Post:index.php.html', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
array('BlogBundle:Post:index.twig.html', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'twig', 'format' => 'html'))),
array('BlogBundle:Post:index.php.xml', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'xml'))),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
Expand Up @@ -14,7 +14,7 @@
<parameter key="twig.loader.class">Symfony\Bundle\TwigBundle\Loader\FilesystemLoader</parameter>
<parameter key="twig.globals.class">Symfony\Bundle\TwigBundle\GlobalVariables</parameter>
<parameter key="twig.form.resources" type="collection">
<parameter>TwigBundle::form.twig</parameter>
<parameter>TwigBundle::form.twig.html</parameter>
</parameter>
<parameter key="templating.engine.twig.class">Symfony\Bundle\TwigBundle\TwigEngine</parameter>
</parameters>
Expand Down
Expand Up @@ -4,6 +4,9 @@

use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\ExceptionController as BaseExceptionController;

/*
* This file is part of the Symfony framework.
Expand All @@ -19,22 +22,21 @@
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ExceptionController extends ContainerAware
class ExceptionController extends BaseExceptionController
{
/**
* Converts an Exception to a Response.
*
* @param \Exception $exception An Exception instance
*
* @throws \InvalidArgumentException When the exception template does not exist
* {@inheritdoc}
*/
public function showAction(FlattenException $exception, $format)
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$template = $this->container->get('kernel')->isDebug() ? 'exception' : 'error';
$code = $this->getStatusCode($exception);

return $this->container->get('templating')->renderResponse(
'FrameworkBundle:Exception:'.$template.'.twig',
'FrameworkBundle:Exception:'.$template.'.twig.html',
array(
'status_code' => $code,
'status_text' => Response::$statusTexts[$code],
'exception' => $exception,
'logger' => null,
'currentContent' => '',
Expand Down
Expand Up @@ -36,7 +36,7 @@ public function panelAction($token, $panel = 'request')
$profiler = $this->container->get('profiler')->loadFromToken($token);

if ($profiler->isEmpty()) {
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:notfound.twig', array('token' => $token));
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:notfound.twig.html', array('token' => $token));
}

if (!$profiler->has($panel)) {
Expand Down Expand Up @@ -146,7 +146,7 @@ public function toolbarAction($token = null, $position = null)
$position = false === strpos($this->container->get('request')->headers->get('user-agent'), 'Mobile') ? 'fixed' : 'absolute';
}

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:toolbar.twig', array(
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:toolbar.twig.html', array(
'position' => $position,
'profiler' => $profiler,
'templates' => $this->getTemplates($profiler),
Expand All @@ -168,7 +168,7 @@ public function searchBarAction($token)
$url = $session->get('_profiler_search_url');
$limit = $session->get('_profiler_search_limit');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:search.twig', array(
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:search.twig.html', array(
'token' => $token,
'profiler' => $profiler,
'tokens' => $profiler->find($ip, $url, $limit),
Expand All @@ -193,7 +193,7 @@ public function searchResultsAction($token)
$url = $session->get('_profiler_search_url');
$limit = $session->get('_profiler_search_limit');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:results.twig', array(
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:results.twig.html', array(
'token' => $token,
'profiler' => $this->container->get('profiler')->loadFromToken($token),
'tokens' => $profiler->find($ip, $url, $limit),
Expand Down Expand Up @@ -246,11 +246,11 @@ protected function getTemplateNames($profiler)
$name = $this->container->get($id)->getName();
$template = $tags[0]['template'];
if ($profiler->has($name)) {
if (!$this->container->get('templating')->exists($template.'.twig')) {
if (!$this->container->get('templating')->exists($template.'.twig.html')) {
continue;
}

$templates[$name] = $template.'.twig';
$templates[$name] = $template.'.twig.html';
}
}
}
Expand Down
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
{% extends 'WebProfilerBundle:Profiler:layout.twig.html' %}

{% block toolbar %}
<img style="margin: 0 5px 0 10px; vertical-align: middle" width="59" height="17" alt="Symfony" src="data:image/png;base64,R0lGODlhOwARAMQdAIZ1X9rVz0owD/Lx78K6r2JML3pnT+bj37asn6qej1Y+H+jk4JKDb0oxEJOEcId2YGJMMPTy8KufkLetoJ+RgNvW0M7Iv56Rf25aP8/JwG5aQP///z4jAP///wAAAAAAACH5BAEAAB0ALAAAAAA7ABEAAAX/YLc8WmmeaKqu7OosYsPNdG3fuCDgfM81C4dvyAsEiEgORZNMGjaI5rBEEzAugBmWBshiOICtAbu7QL+Ky8UwExQw6i8HTqPPqJzCYMMPCDYWNBYWBRsHfIaIgWYbWIiAHAF7iAkcZjSXd0wchwQYCBZ/gTODHAQbngEbARincBsYGAMDAK2NAKsGBodpG5i+mjMGewg7HJCki7AcT18YG1e+DBtZMweBjTO4r780eHmqAQXHoxylZs7Lz2q+6IIDxxczz6/GmRzfBQKnAxgWG+MiKUuXjh0zVDMKEYg3DxYueRwSAMO3SSKBfwMEPBtA4NDAOeoaZQp3alk2kBgEVJDk421TgX+AAu5SZClkwUwCEPA5wIYhSg4KYO5pieRZFClIrcELNkTAHgVJkUqEyOGBBCRdoiItUInGhAgQtIpNoqGD2Qxo06pdy7at27dvK5gNAQA7" />
Expand Down
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
{% extends 'WebProfilerBundle:Profiler:layout.twig.html' %}

{% block menu %}
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Events" src="{{ asset('bundles/webprofiler/images/events.png') }}" />
Expand Down
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
{% extends 'WebProfilerBundle:Profiler:layout.twig.html' %}

{% block head %}
<link href="{{ asset('bundles/framework/css/exception.css') }}" rel="stylesheet" type="text/css" media="screen" />
Expand Down
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}
{% extends 'WebProfilerBundle:Profiler:layout.twig.html' %}

{% block toolbar %}
<img style="margin: 0 5px 0 10px; vertical-align: middle; height: 24px" width="24" height="24" alt="Logs" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAApBJREFUeNrsl19oUlEcx+91dp24hgMXhmvYZokaC5Uon+ollk/14JMIw8c9zpfwJeglqMfoVXQw9KknAyNFfagRyNaiB7Mw3VDxz9iG/xH/9D10HSJxJ9oSyh98OOd47u+c7/2ec/AeutPpUOMMHjXm4HN10jTdrc6Ax+AOOATvwWe2PDO4XKY5O38JUIjF4uc2m023vLwsa7Va+XQ6Hdne3m56vV4BK+QD2HO73dn+Mcxm80gCHqhUKvvGxsYNhmEyHo/nVbvdvryysiJUKpW3hEKhtlwuf4pEIgfBYJBJJpMVIoQI2traIiVlsViGF2A0GqMmk+lqvV5/HQqFnAsLC/cFAsFSLpc7TKVSBfzekEqlfIPBcAUu3YZgXjab/er3+8vhcHgKQ/wgYjDH26EEbG5udjBR0eVyxWZnZ79ptdoThULRgohOtVoVgZlisdiOx+P7tVqtgZSGTqebxjMGPHMN7uz7fL5LQDWUAKfTedqZSCSOo9HoUSwWK2KyI41GE1Wr1VWJRMI0m80LlUrlYqlUYrA/8ohjtBvr6+tkf7yxWq30UKcAG+60vri4OEdYXV2l8OaN3d3d64FA4LhQKNTn5+e/6PX6A7lcPiWTyaYzmcxN7BUa+c9GOoa9AnoD9jJk3QmkDVeWdnZ28rC6bLfbLXDkBVf+yAL6A2suIbA538nb/1UB/QEB1L8hAGs5lIDuxIPkTxyYODBZgokD5yKgmzf5L/gTAqwo7oJHQHweAjgvJg6Hw4XBrGAOaMFTsEcm4ILMLRKJ0mzbxXn3OOtesLa29rsuObgHHrJlrzs0jt8TPp//DvWP+LDl/CznD2pnXySBi4XqE0PxeLyXyDsZZLno//5yOnYBPwUYACFn5hv7UNkXAAAAAElFTkSuQmCC" />
Expand Down

0 comments on commit a365ab2

Please sign in to comment.