Thomas Rabaix 13 anni fa
parent
commit
697497beda

+ 1 - 1
Admin/FieldDescriptionInterface.php

@@ -172,7 +172,7 @@ interface FieldDescriptionInterface
      * @param array $parentAssociationMappings
      * @return void
      */
-    function setParentAssociationMappings($parentAssociationMappings);
+    function setParentAssociationMappings(array $parentAssociationMappings);
 
     /**
      * return the parent association mapping definitions

+ 4 - 0
CHANGELOG.md

@@ -1,6 +1,10 @@
 CHANGELOG
 =========
 
+### 2012-05-02
+
+* [BC BREAK] add ProxyQueryInterface hint into the FilterInterface class
+
 ### 2012-03-07
 
 * [BC BREAK] Extension : refactor the AdminExtensionInterface to use the proper AdminInterface, add a new configureQuery method

+ 55 - 1
Datagrid/ProxyQueryInterface.php

@@ -10,31 +10,85 @@
 
 namespace Sonata\AdminBundle\Datagrid;
 
-
 /**
  * Interface used by the Datagrid to build the query
  */
 interface ProxyQueryInterface
 {
+    /**
+     *
+     * @param array $params
+     * @param null $hydrationMode
+     * @return mixed
+     */
     function execute(array $params = array(), $hydrationMode = null);
 
+    /**
+     * @param $name
+     * @param $args
+     * @return mixed
+     */
     function __call($name, $args);
 
+    /**
+     * @param $parentAssociationMappings
+     * @param $fieldMapping
+     * @return mixed
+     */
     function setSortBy($parentAssociationMappings, $fieldMapping);
 
+    /**
+     * @return mixed
+     */
     function getSortBy();
 
+    /**
+     * @param $sortOrder
+     * @return mixed
+     */
     function setSortOrder($sortOrder);
 
+    /**
+     * @abstract
+     * @return mixed
+     */
     function getSortOrder();
 
+    /**
+     * @return mixed
+     */
     function getSingleScalarResult();
 
+    /**
+     * @param $firstResult
+     * @return mixed
+     */
     function setFirstResult($firstResult);
 
+    /**
+     * @return mixed
+     */
     function getFirstResult();
 
+    /**
+     * @param $maxResults
+     * @return mixed
+     */
     function setMaxResults($maxResults);
 
+    /**
+     * @return mixed
+     */
     function getMaxResults();
+
+    /**
+     * @return mixed
+     */
+    function getUniqueParameterId();
+
+    /**
+     * @param array $associationMappings
+     * @return mixed
+     */
+    function entityJoin(array $associationMappings);
 }

+ 13 - 17
Filter/Filter.php

@@ -28,8 +28,7 @@ abstract class Filter implements FilterInterface
     const CONDITION_AND = 'AND';
 
     /**
-     * @param string $name
-     * @param array $options
+     * {@inheritdoc}
      */
     public function initialize($name, array $options = array())
     {
@@ -38,7 +37,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return string
+     * {@inheritdoc}
      */
     public function getName()
     {
@@ -46,7 +45,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return string
+     * {@inheritdoc}
      */
     public function getFormName()
     {
@@ -59,9 +58,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @param string $name
-     * @param null $default
-     * @return mixed
+     * {@inheritdoc}
      */
     public function getOption($name, $default = null)
     {
@@ -73,8 +70,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @param $name
-     * @param $value
+     * {@inheritdoc}
      */
     public function setOption($name, $value)
     {
@@ -82,7 +78,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return string
+     * {@inheritdoc}
      */
     public function getFieldType()
     {
@@ -90,7 +86,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return array
+     * {@inheritdoc}
      */
     public function getFieldOptions()
     {
@@ -98,7 +94,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return string
+     * {@inheritdoc}
      */
     public function getLabel()
     {
@@ -106,7 +102,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @param $label
+     * {@inheritdoc}
      */
     public function setLabel($label)
     {
@@ -114,7 +110,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return string
+     * {@inheritdoc}
      */
     public function getFieldName()
     {
@@ -128,7 +124,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return array of mappings
+     * {@inheritdoc}
      */
     public function getParentAssociationMappings()
     {
@@ -136,7 +132,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return array field mapping
+     * {@inheritdoc}
      */
     public function getFieldMapping()
     {
@@ -150,7 +146,7 @@ abstract class Filter implements FilterInterface
     }
 
     /**
-     * @return array association mapping
+     * {@inheritdoc}
      */
     public function getAssociationMapping()
     {

+ 7 - 18
Filter/FilterInterface.php

@@ -11,22 +11,22 @@
 
 namespace Sonata\AdminBundle\Filter;
 
+use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
+
 interface FilterInterface
 {
     /**
      * Apply the filter to the QueryBuilder instance
      *
-     * @abstract
-     * @param $queryBuilder
+     * @param ProxyQueryInterface $queryBuilder
      * @param string $alias
      * @param string $field
      * @param string $value
      * @return void
      */
-    function filter($queryBuilder, $alias, $field, $value);
+    function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $value);
 
     /**
-     * @abstract
      * @param $query
      * @param $value
      */
@@ -34,14 +34,14 @@ interface FilterInterface
 
     /**
      * Returns the filter name
-     * @abstract
+     *
      * @return string
      */
     function getName();
 
     /**
      * Returns the filter form name
-     * @abstract
+     *
      * @return string
      */
     function getFormName();
@@ -49,26 +49,21 @@ interface FilterInterface
     /**
      * Returns the label name
      *
-     * @abstract
      * @return string
      */
     function getLabel();
 
     /**
-     * @abstract
-     *
      * @param string $label
      */
-    function setLabel($name);
+    function setLabel($label);
 
     /**
-     * @abstract
      * @return array
      */
     function getDefaultOptions();
 
     /**
-     * @abstract
      * @param string $name
      * @param null $default
      * @return mixed
@@ -76,14 +71,12 @@ interface FilterInterface
     function getOption($name, $default = null);
 
     /**
-     * @abstract
      * @param $name
      * @param $value
      */
     function setOption($name, $value);
 
     /**
-     * @abstract
      * @param $name
      * @param array $options
      * @return void
@@ -91,7 +84,6 @@ interface FilterInterface
     function initialize($name, array $options = array());
 
     /**
-     * @abstract
      * @return string
      */
     function getFieldName();
@@ -112,13 +104,11 @@ interface FilterInterface
     function getAssociationMapping();
 
     /**
-     * @abstract
      * @return array
      */
     function getFieldOptions();
 
     /**
-     * @abstract
      * @return string
      */
     function getFieldType();
@@ -126,7 +116,6 @@ interface FilterInterface
     /**
      * Returns the main widget used to render the filter
      *
-     * @abstract
      * @return array
      */
     function getRenderSettings();

+ 1 - 1
Tests/Admin/BaseFieldDescriptionTest.php

@@ -146,7 +146,7 @@ class FieldDescription extends BaseFieldDescription
      * @param array $parentAssociationMappings
      * @return void
      */
-    function setParentAssociationMappings($parentAssociationMappings)
+    function setParentAssociationMappings(array $parentAssociationMappings)
     {
         // TODO: Implement setParentAssociationMappings() method.
     }

+ 2 - 1
Tests/Filter/FilterTest.php

@@ -12,10 +12,11 @@
 namespace Sonata\AdminBundle\Tests\Filter;
 
 use Sonata\AdminBundle\Filter\Filter;
+use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
 
 class FilterTest_Filter extends Filter
 {
-    function filter($queryBuilder, $alias, $field, $value)
+    function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $value)
     {
     }