Просмотр исходного кода

Merge pull request #4282 from greg0ire/twig_2_support

Twig 2 support
Oskar Stark 8 лет назад
Родитель
Сommit
983bc715f0

+ 3 - 2
Resources/views/CRUD/list_array.html.twig

@@ -8,10 +8,11 @@ For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.
 
 #}
+{% import _self as list %}
 {%  macro render_array(value) %}
     {% for key, val in value %}
         {% if val is iterable %}
-            [{{ key }} => {{ _self.render_array(val) }}}]
+            [{{ key }} => {{ list.render_array(val) }}}]
         {%  else %}
             [{{ key }} => {{ val }}]
         {%  endif %}
@@ -21,5 +22,5 @@ file that was distributed with this source code.
 {% extends admin.getTemplate('base_list_field') %}
 
 {% block field %}
-    {{ _self.render_array(value) }}
+    {{ list.render_array(value) }}
 {% endblock %}

+ 3 - 0
Resources/views/Core/tab_menu_template.html.twig

@@ -83,6 +83,7 @@
 {% endblock %}
 
 {% block linkElement %}
+    {% import "knp_menu.html.twig" as macros %}
     <a href="{{ item.uri }}"{{ macros.attributes(item.linkAttributes) }}>
         {% if item.attribute('icon') is not empty  %}
             <i class="{{ item.attribute('icon') }}"></i>
@@ -92,6 +93,7 @@
 {% endblock %}
 
 {% block spanElement %}
+    {% import "knp_menu.html.twig" as macros %}
     <span {{ macros.attributes(item.labelAttributes) }}>
         {% if item.attribute('icon') is not empty  %}
             <i class="{{ item.attribute('icon') }}"></i>
@@ -101,6 +103,7 @@
 {% endblock %}
 
 {% block dropdownElement %}
+    {% import "knp_menu.html.twig" as macros %}
     {%- set classes = item.linkAttribute('class') is not empty ? [item.linkAttribute('class')] : [] %}
     {%- set classes = classes|merge(['dropdown-toggle']) %}
     {%- set attributes = item.linkAttributes %}

+ 4 - 0
Tests/Twig/Extension/SonataAdminExtensionTest.php

@@ -90,6 +90,10 @@ class SonataAdminExtensionTest extends PHPUnit_Framework_TestCase
 
     public function setUp()
     {
+        // NEXT_MAJOR: remove this block when dropping symfony < 2.7 support
+        if (!class_exists('Symfony\Bridge\Twig\Extension\AssetExtension')) {
+            $this->markTestSkipped();
+        }
         date_default_timezone_set('Europe/London');
 
         $container = $this->getMockForAbstractClass('Symfony\Component\DependencyInjection\ContainerInterface');

+ 1 - 1
composer.json

@@ -40,7 +40,7 @@
         "symfony/twig-bridge": "^2.3.5 || ^3.0",
         "symfony/validator": "^2.3 || ^3.0",
         "twig/extensions": "^1.0",
-        "twig/twig": "^1.28"
+        "twig/twig": "^1.28 || ^2.0"
     },
     "require-dev": {
         "jms/di-extra-bundle": "^1.7",