[TwigBundle] removed usage of Templating classes

This commit is contained in:
Fabien Potencier 2015-09-28 15:28:45 +02:00
parent 7f13f9537c
commit ff3c107f14
16 changed files with 23 additions and 25 deletions

View File

@ -11,12 +11,10 @@
namespace Symfony\Bundle\TwigBundle\Controller; namespace Symfony\Bundle\TwigBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Component\HttpKernel\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Templating\TemplateReferenceInterface;
/** /**
* ExceptionController renders error or exception pages for a given * ExceptionController renders error or exception pages for a given
@ -96,7 +94,7 @@ class ExceptionController
* @param int $code An HTTP response status code * @param int $code An HTTP response status code
* @param bool $showException * @param bool $showException
* *
* @return TemplateReferenceInterface * @return string
*/ */
protected function findTemplate(Request $request, $format, $code, $showException) protected function findTemplate(Request $request, $format, $code, $showException)
{ {
@ -107,14 +105,14 @@ class ExceptionController
// For error pages, try to find a template for the specific HTTP status code and format // For error pages, try to find a template for the specific HTTP status code and format
if (!$showException) { if (!$showException) {
$template = new TemplateReference('TwigBundle', 'Exception', $name.$code, $format, 'twig'); $template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) { if ($this->templateExists($template)) {
return $template; return $template;
} }
} }
// try to find a template for the given format // try to find a template for the given format
$template = new TemplateReference('TwigBundle', 'Exception', $name, $format, 'twig'); $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format);
if ($this->templateExists($template)) { if ($this->templateExists($template)) {
return $template; return $template;
} }
@ -122,7 +120,7 @@ class ExceptionController
// default to a generic HTML exception // default to a generic HTML exception
$request->setRequestFormat('html'); $request->setRequestFormat('html');
return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig'); return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
} }
// to be removed when the minimum required version of Twig is >= 3.0 // to be removed when the minimum required version of Twig is >= 3.0

View File

@ -1 +1 @@
{% include 'TwigBundle:Exception:error.xml.twig' %} {% include '@Twig/Exception/error.xml.twig' %}

View File

@ -1 +1 @@
{% include 'TwigBundle:Exception:error.xml.twig' %} {% include '@Twig/Exception/error.xml.twig' %}

View File

@ -1 +1 @@
{% include 'TwigBundle:Exception:exception.xml.twig' with { 'exception': exception } %} {% include '@Twig/Exception/exception.xml.twig' with { 'exception': exception } %}

View File

@ -1,3 +1,3 @@
/* /*
{% include 'TwigBundle:Exception:exception.txt.twig' with { 'exception': exception } %} {% include '@Twig/Exception/exception.txt.twig' with { 'exception': exception } %}
*/ */

View File

@ -37,7 +37,7 @@
</div> </div>
{% for position, e in exception.toarray %} {% for position, e in exception.toarray %}
{% include 'TwigBundle:Exception:traces.html.twig' with { 'exception': e, 'position': position, 'count': previous_count } only %} {% include '@Twig/Exception/traces.html.twig' with { 'exception': e, 'position': position, 'count': previous_count } only %}
{% endfor %} {% endfor %}
{% if logger %} {% if logger %}
@ -63,7 +63,7 @@
</div> </div>
<div id="logs"> <div id="logs">
{% include 'TwigBundle:Exception:logs.html.twig' with { 'logs': logger.logs } only %} {% include '@Twig/Exception/logs.html.twig' with { 'logs': logger.logs } only %}
</div> </div>
</div> </div>
{% endif %} {% endif %}
@ -88,7 +88,7 @@
</div> </div>
{% endif %} {% endif %}
{% include 'TwigBundle:Exception:traces_text.html.twig' with { 'exception': exception } only %} {% include '@Twig/Exception/traces_text.html.twig' with { 'exception': exception } only %}
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
function toggle(id, clazz) { function toggle(id, clazz) {

View File

@ -1,3 +1,3 @@
/* /*
{% include 'TwigBundle:Exception:exception.txt.twig' with { 'exception': exception } %} {% include '@Twig/Exception/exception.txt.twig' with { 'exception': exception } %}
*/ */

View File

@ -1 +1 @@
{% include 'TwigBundle:Exception:exception.xml.twig' with { 'exception': exception } %} {% include '@Twig/Exception/exception.xml.twig' with { 'exception': exception } %}

View File

@ -2,6 +2,6 @@
[message] {{ exception.message }} [message] {{ exception.message }}
{% for i, e in exception.toarray %} {% for i, e in exception.toarray %}
[{{ i + 1 }}] {{ e.class }}: {{ e.message }} [{{ i + 1 }}] {{ e.class }}: {{ e.message }}
{% include 'TwigBundle:Exception:traces.txt.twig' with { 'exception': e } only %} {% include '@Twig/Exception/traces.txt.twig' with { 'exception': e } only %}
{% endfor %} {% endfor %}

View File

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

View File

@ -1,4 +1,4 @@
{% extends 'TwigBundle::layout.html.twig' %} {% extends '@Twig/layout.html.twig' %}
{% block head %} {% block head %}
<link href="{{ absolute_url(asset('bundles/framework/css/exception.css')) }}" rel="stylesheet" type="text/css" media="all" /> <link href="{{ absolute_url(asset('bundles/framework/css/exception.css')) }}" rel="stylesheet" type="text/css" media="all" />
@ -9,5 +9,5 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% include 'TwigBundle:Exception:exception.html.twig' %} {% include '@Twig/Exception/exception.html.twig' %}
{% endblock %} {% endblock %}

View File

@ -18,7 +18,7 @@
<ol class="traces list-exception" id="traces-{{ position }}" style="display: {{ 0 == count ? 'block' : 'none' }}"> <ol class="traces list-exception" id="traces-{{ position }}" style="display: {{ 0 == count ? 'block' : 'none' }}">
{% for i, trace in exception.trace %} {% for i, trace in exception.trace %}
<li> <li>
{% include 'TwigBundle:Exception:trace.html.twig' with { 'prefix': position, 'i': i, 'trace': trace } only %} {% include '@Twig/Exception/trace.html.twig' with { 'prefix': position, 'i': i, 'trace': trace } only %}
</li> </li>
{% endfor %} {% endfor %}
</ol> </ol>

View File

@ -1,6 +1,6 @@
{% if exception.trace|length %} {% if exception.trace|length %}
{% for trace in exception.trace %} {% for trace in exception.trace %}
{% include 'TwigBundle:Exception:trace.txt.twig' with { 'trace': trace } only %} {% include '@Twig/Exception/trace.txt.twig' with { 'trace': trace } only %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

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

View File

@ -12,7 +12,7 @@
<div id="traces-text" class="trace" style="display: none;"> <div id="traces-text" class="trace" style="display: none;">
<pre>{% for i, e in exception.toarray %} <pre>{% for i, e in exception.toarray %}
[{{ i + 1 }}] {{ e.class }}: {{ e.message }} [{{ i + 1 }}] {{ e.class }}: {{ e.message }}
{% include 'TwigBundle:Exception:traces.txt.twig' with { 'exception': e } only %} {% include '@Twig/Exception/traces.txt.twig' with { 'exception': e } only %}
{% endfor %}</pre> {% endfor %}</pre>
</div> </div>
</div> </div>

View File

@ -47,7 +47,7 @@ class ExceptionControllerTest extends TestCase
{ {
$twig = new \Twig_Environment( $twig = new \Twig_Environment(
new \Twig_Loader_Array(array( new \Twig_Loader_Array(array(
'TwigBundle:Exception:error404.html.twig' => 'ok', '@Twig/Exception/error404.html.twig' => 'ok',
)) ))
); );
@ -67,7 +67,7 @@ class ExceptionControllerTest extends TestCase
{ {
$twig = new \Twig_Environment( $twig = new \Twig_Environment(
new \Twig_Loader_Array(array( new \Twig_Loader_Array(array(
'TwigBundle:Exception:error.html.twig' => 'html', '@Twig/Exception/error.html.twig' => 'html',
)) ))
); );