Browse Source

Merge branch '2.3'

Conflicts:
	Resources/views/CRUD/base_list.html.twig
	Resources/views/Form/form_admin_fields.html.twig
	Twig/Extension/SonataAdminExtension.php
Sullivan SENECHAL 9 years ago
parent
commit
4cb18ef833

+ 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>
     <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 %}
         {% set count = 0 %}
         <div class="row">
         <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 %}
 {% block checkbox_widget %}
     {% spaceless %}
     {% 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 %}
             {% set label = name|humanize %}
         {% endif %}
         {% endif %}
         {% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes %}
         {% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes %}

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

@@ -88,7 +88,7 @@ file that was distributed with this source code.
     {% set label_class = label_class|default('') ~ ' control-label' %}
     {% set label_class = label_class|default('') ~ ' control-label' %}
 
 
     {#{{ sonata_admin.admin.getConfigurationPool().getOption('form_type') }}#}
     {#{{ 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 }) %}
         {% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ label_class }) %}
 
 
         {% if not compound %}
         {% if not compound %}

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

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

+ 10 - 28
Twig/Extension/SonataAdminExtension.php

@@ -65,31 +65,15 @@ class SonataAdminExtension extends \Twig_Extension
     public function getFilters()
     public function getFilters()
     {
     {
         return array(
         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 getFunctions()
-    {
-        return array();
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getTokenParsers()
-    {
-        return array();
-    }
-
     /**
     /**
      * {@inheritdoc}
      * {@inheritdoc}
      */
      */
@@ -104,7 +88,7 @@ class SonataAdminExtension extends \Twig_Extension
      * @param FieldDescriptionInterface $fieldDescription
      * @param FieldDescriptionInterface $fieldDescription
      * @param string                    $defaultTemplate
      * @param string                    $defaultTemplate
      *
      *
-     * @return \Twig_TemplateInterface
+     * @return \Twig_Template
      */
      */
     protected function getTemplate(FieldDescriptionInterface $fieldDescription, $defaultTemplate)
     protected function getTemplate(FieldDescriptionInterface $fieldDescription, $defaultTemplate)
     {
     {
@@ -146,12 +130,12 @@ class SonataAdminExtension extends \Twig_Extension
 
 
     /**
     /**
      * @param FieldDescriptionInterface $fieldDescription
      * @param FieldDescriptionInterface $fieldDescription
-     * @param \Twig_TemplateInterface   $template
+     * @param \Twig_Template            $template
      * @param array                     $parameters
      * @param array                     $parameters
      *
      *
      * @return string
      * @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);
         $content = $template->render($parameters);
 
 
@@ -323,9 +307,7 @@ class SonataAdminExtension extends \Twig_Extension
     public function getUrlsafeIdentifier($model, AdminInterface $admin = null)
     public function getUrlsafeIdentifier($model, AdminInterface $admin = null)
     {
     {
         if (is_null($admin)) {
         if (is_null($admin)) {
-            $admin = $this->pool->getAdminByClass(
-                ClassUtils::getClass($model)
-            );
+            $admin = $this->pool->getAdminByClass(ClassUtils::getClass($model));
         }
         }
 
 
         return $admin->getUrlsafeIdentifier($model);
         return $admin->getUrlsafeIdentifier($model);