Author: Leon.van.der.Ree
Date: 2010-03-25 17:58:57 +0100 (Thu, 25 Mar 2010)
New Revision: 28788
Modified:
plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php
plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php
Log:
started re-implementation of filtering of dataSources.
Modified: plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php
===================================================================
--- plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php
2010-03-25 14:53:45 UTC (rev 28787)
+++ plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php
2010-03-25 16:58:57 UTC (rev 28788)
@@ -100,6 +100,10 @@
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))
*
@@ -107,7 +111,7 @@
*
* @param array[array[string, string]] $columns
*/
- public function setFilter($fields);
+ public function addFilter($column, $value, $comparison = Criteria::EQUAL);
/**
* Sets the number of rows to skip in the beginning of the data source when
Modified: plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php
===================================================================
--- plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php
2010-03-25 14:53:45 UTC (rev 28787)
+++ plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php
2010-03-25 16:58:57 UTC (rev 28788)
@@ -385,9 +385,31 @@
/**
* @see sfDataSourceInterface
*/
- public function setFilter($fields)
+ // TODO: remove Criteria dependancy
+ public function addFilter($column, $value, $comparison = Criteria::EQUAL)
{
- throw new Exception('This method has not been implemented yet');
+ $this->requireColumn($column);
+
+ $query = $this->query;
+
+ // is you have a query object
+ if ($this->query)
+ {
+ // check if an objectPath has been given
+ $lastDot = strrpos($column, '.');
+ if ($lastDot !== false)
+ {
+ // get the objectPath
+ $objectPath = substr($column, 0, $lastDot);
+
+ // and get Related Query Class
+ $strRelated = $query->translateObjectPathToAlias($objectPath);
+ $query = $query->useQuery($strRelated);
+ $column = substr($column, $lastDot + 1);
+ }
+ }
+
+ $query->filterBy($column, $value, $comparison);
}
}
\ No newline at end of file
--
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.