Selaa lähdekoodia

Remove usage of deprecated Twig stuff

Konstantin.Myakshin 9 vuotta sitten
vanhempi
commit
9a05d8e75f

+ 1 - 1
Resources/views/CRUD/base_list.html.twig

@@ -206,7 +206,7 @@ file that was distributed with this source code.
                         <div class="filter_container {{ admin.datagrid.hasActiveFilters ? 'active' : 'inactive' }}">
                             {% for filter in admin.datagrid.filters %}
                                 <div class="form-group">
-                                    {% if filter.label is not sameas(false) %}
+                                    {% if filter.label is not same as(false) %}
                                     <label for="{{ form.children[filter.formName].children['value'].vars.id }}">{{ admin.trans(filter.label, {}, filter.translationDomain) }}</label>
                                     {% endif %}
                                     {% set attr = form.children[filter.formName].children['type'].vars.attr|default({}) %}

+ 1 - 1
Resources/views/Core/search.html.twig

@@ -27,7 +27,7 @@ file that was distributed with this source code.
 
     <h1>{{ 'title_search_results'|trans({'%query%': query}, 'SonataAdminBundle') }}</h1>
 
-    {% if query is defined and query is not sameas(false) %}
+    {% if query is defined and query is not same as(false) %}
         {% set count = 0 %}
         <div class="row">
 

+ 1 - 1
Resources/views/Form/filter_admin_fields.html.twig

@@ -59,7 +59,7 @@ file that was distributed with this source code.
 
 {% block checkbox_widget %}
     {% spaceless %}
-        {% if label is not sameas(false) and label is empty %}
+        {% if label is not same as(false) and label is empty %}
             {% set label = name|humanize %}
         {% endif %}
         {% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes %}

+ 3 - 3
Resources/views/Form/form_admin_fields.html.twig

@@ -40,7 +40,7 @@ file that was distributed with this source code.
     {% endif%}
 
     {#{{ sonata_admin.admin.getConfigurationPool().getOption('form_type') }}#}
-    {% if label is not sameas(false) %}
+    {% if label is not same as(false) %}
         {% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ label_class }) %}
 
         {% if not compound %}
@@ -153,7 +153,7 @@ file that was distributed with this source code.
     {% if sonata_admin is not defined or not sonata_admin_enabled or not sonata_admin.field_description %}
         <div class="form-group {% if errors|length > 0%} has-error{% endif %}">
             {{ form_label(form, label|default(null)) }}
-            <div class="{% if label is sameas(false) %}sonata-collection-row-without-label{% endif %}">
+            <div class="{% if label is same as(false) %}sonata-collection-row-without-label{% endif %}">
                 {{ form_widget(form, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #}
                 {% if errors|length > 0 %}
                     <div class="help-block sonata-ba-field-error-messages">
@@ -172,7 +172,7 @@ file that was distributed with this source code.
                 {% endif %}
             {% endblock %}
 
-            {% set has_label = sonata_admin.field_description.options.name is defined or label is not sameas(false) %}
+            {% set has_label = sonata_admin.field_description.options.name is defined or label is not same as(false) %}
             <div class="{{ div_class }} sonata-ba-field sonata-ba-field-{{ sonata_admin.edit }}-{{ sonata_admin.inline }} {% if errors|length > 0 %}sonata-ba-field-error{% endif %} {% if not has_label %}sonata-collection-row-without-label{% endif %}">
 
                 {{ form_widget(form, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #}

+ 1 - 1
Tests/Twig/Extension/SonataAdminExtensionTest.php

@@ -41,7 +41,7 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
     private $twigExtension;
 
     /**
-     * @var Twig_Environment
+     * @var \Twig_Environment
      */
     private $environment;
 

+ 10 - 20
Twig/Extension/SonataAdminExtension.php

@@ -59,23 +59,15 @@ class SonataAdminExtension extends \Twig_Extension
     public function getFilters()
     {
         return array(
-            'render_list_element'           => new \Twig_Filter_Method($this, 'renderListElement', array('is_safe' => array('html'))),
-            'render_view_element'           => new \Twig_Filter_Method($this, 'renderViewElement', array('is_safe' => array('html'))),
-            'render_view_element_compare'   => new \Twig_Filter_Method($this, 'renderViewElementCompare', array('is_safe' => array('html'))),
-            'render_relation_element'       => new \Twig_Filter_Method($this, 'renderRelationElement'),
-            'sonata_urlsafeid'              => new \Twig_Filter_Method($this, 'getUrlsafeIdentifier'),
-            'sonata_xeditable_type'         => new \Twig_Filter_Method($this, 'getXEditableType'),
+            new \Twig_SimpleFilter('render_list_element', array($this, 'renderListElement'), array('is_safe' => array('html'))),
+            new \Twig_SimpleFilter('render_view_element', array($this, 'renderViewElement'), array('is_safe' => array('html'))),
+            new \Twig_SimpleFilter('render_view_element_compare', array($this, 'renderViewElementCompare'), array('is_safe' => array('html'))),
+            new \Twig_SimpleFilter('render_relation_element', array($this, 'renderRelationElement')),
+            new \Twig_SimpleFilter('sonata_urlsafeid', array($this, 'getUrlsafeIdentifier')),
+            new \Twig_SimpleFilter('sonata_xeditable_type', array($this, 'getXEditableType')),
         );
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    public function getTokenParsers()
-    {
-        return array();
-    }
-
     /**
      * {@inheritdoc}
      */
@@ -90,7 +82,7 @@ class SonataAdminExtension extends \Twig_Extension
      * @param FieldDescriptionInterface $fieldDescription
      * @param string                    $defaultTemplate
      *
-     * @return \Twig_TemplateInterface
+     * @return \Twig_Template
      */
     protected function getTemplate(FieldDescriptionInterface $fieldDescription, $defaultTemplate)
     {
@@ -132,12 +124,12 @@ class SonataAdminExtension extends \Twig_Extension
 
     /**
      * @param FieldDescriptionInterface $fieldDescription
-     * @param \Twig_TemplateInterface   $template
+     * @param \Twig_Template            $template
      * @param array                     $parameters
      *
      * @return string
      */
-    public function output(FieldDescriptionInterface $fieldDescription, \Twig_TemplateInterface $template, array $parameters = array())
+    public function output(FieldDescriptionInterface $fieldDescription, \Twig_Template $template, array $parameters = array())
     {
         $content = $template->render($parameters);
 
@@ -303,9 +295,7 @@ class SonataAdminExtension extends \Twig_Extension
      */
     public function getUrlsafeIdentifier($model)
     {
-        $admin = $this->pool->getAdminByClass(
-            ClassUtils::getClass($model)
-        );
+        $admin = $this->pool->getAdminByClass(ClassUtils::getClass($model));
 
         return $admin->getUrlsafeIdentifier($model);
     }