Author: Leon.van.der.Ree
Date: 2010-05-12 16:55:25 +0200 (Wed, 12 May 2010)
New Revision: 29423

Added:
   plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceAggregatedFiltering.php
   plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceFilterableInterface.php
Modified:
   plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php
   plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php
Log:
added aggregator for filtering

Added: plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceAggregatedFiltering.php
===================================================================
--- plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceAggregatedFiltering.php    
                        (rev 0)
+++ plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceAggregatedFiltering.php    
2010-05-12 14:55:25 UTC (rev 29423)
@@ -0,0 +1,62 @@
+<?php
+/*
+ * This file is part of the symfony package.
+ * (c) Leon van der Ree <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * This class aggregates filtering over dataSources
+ * @package    symfony
+ * @subpackage grid
+ * @author     Leon van der Ree <[email protected]>
+ * @version    SVN: $Id$
+ */
+class sfDataSourceAggregatedFiltering implements 
sfDataSourceFilterableInterface
+{
+  protected $dataSources = array();
+  
+  /**
+   * 
+   * @param array[sfDataSourceAggregatedFiltering] $dataSources
+   */
+  public function __construct($dataSources = array())
+  {
+    foreach ($dataSources as $dataSource)
+    {
+      $this->addDataSource($dataSource);
+    }
+  }
+  
+  /**
+   * add a dataSource to the list of sources to be filtered
+   * 
+   * @param sfDataSourceAggregatedFiltering $dataSource
+   */
+  public function addDataSource(sfDataSourceFilterableInterface $dataSource)
+  {
+    $this->dataSources[] = $dataSource;
+  }
+  
+  /**
+   * @return sfDataSourceAggregatedFiltering
+   */
+  public function getDataSources()
+  {
+    return $this->dataSources;
+  } 
+  
+  /**
+   * @see sfDataSourceFilterableInterface::addFilter
+   */
+  public function addFilter($column, $value, $comparison = sfDataSource::EQUAL)
+  {
+    foreach ($this->dataSources as $dataSource)
+    {
+      $dataSource->addFilter($column, $value, $comparison);
+    }
+  }
+  
+}
\ No newline at end of file

Added: plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceFilterableInterface.php
===================================================================
--- plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceFilterableInterface.php    
                        (rev 0)
+++ plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceFilterableInterface.php    
2010-05-12 14:55:25 UTC (rev 29423)
@@ -0,0 +1,30 @@
+<?php
+/*
+ * This file is part of the symfony package.
+ * (c) Leon van der Ree <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * This interface allows filtering of dataSources
+ * @package    symfony
+ * @subpackage grid
+ * @author     Leon van der Ree <[email protected]>
+ * @version    SVN: $Id$
+ */
+interface sfDataSourceFilterableInterface
+{
+  /**
+   * 
+   * An associative array of field-names with an associative array of 
value/operator-pairs
+   * array(field => array('value' => $value, 'operator' => $operator))
+   *
+   * field names can match column-names but the implementation is up to you.
+   *
+   * @param array[array[string, string]] $columns
+   */
+  public function addFilter($column, $value, $comparison = 
sfDataSource::EQUAL);
+
+}
\ No newline at end of file

Modified: plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php
===================================================================
--- plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php        
2010-05-12 14:11:21 UTC (rev 29422)
+++ plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php        
2010-05-12 14:55:25 UTC (rev 29423)
@@ -61,7 +61,7 @@
  * @author     Bernhard Schussek <[email protected]>
  * @version    SVN: $Id$
  */
-interface sfDataSourceInterface extends SeekableIterator, ArrayAccess, 
Countable
+interface sfDataSourceInterface extends SeekableIterator, ArrayAccess, 
Countable, sfDataSourceFilterableInterface
 {
   const ASC  = 'asc';
   const DESC = 'desc';
@@ -100,20 +100,6 @@
   public function setSort($column, $order = sfDataSourceInterface::ASC);
 
   /**
-   * 
-   * // TODO: remove Criteria dependancy
-   * 
-   * 
-   * An associative array of field-names with an associative array of 
value/operator-pairs
-   * array(field => array('value' => $value, 'operator' => $operator))
-   *
-   * field names can match column-names but the implementation is up to you.
-   *
-   * @param array[array[string, string]] $columns
-   */
-  public function addFilter($column, $value, $comparison = 
sfDataSource::EQUAL);
-
-  /**
    * Sets the number of rows to skip in the beginning of the data source when
    * iterating. If set to 0, no rows are skipped.
    *

Modified: plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php
===================================================================
--- plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php   
2010-05-12 14:11:21 UTC (rev 29422)
+++ plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php   
2010-05-12 14:55:25 UTC (rev 29423)
@@ -158,7 +158,10 @@
     foreach ($accessors as $accessor)
     {
       $method = 'get'.$accessor; //TODO: maybe move to 
sfPropelObjectPathBehaviorPlugin? object->getValueByPropertyPath($field)...
-      $obj = $obj->$method();
+      if ($obj)
+      {
+        $obj = $obj->$method();
+      }
     }
     
     return $obj;

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to