Development

Changeset 28788

You must first sign up to be able to contribute.

Changeset 28788

Show
Ignore:
Timestamp:
03/25/10 17:58:57 (3 years ago)
Author:
Leon.van.der.Ree
Message:

started re-implementation of filtering of dataSources.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfDataSourcePlugin/trunk/lib/sfDataSourceInterface.class.php

    r28744 r28788  
    101101 
    102102  /** 
     103   *  
     104   * // TODO: remove Criteria dependancy 
     105   *  
     106   *  
    103107   * An associative array of field-names with an associative array of value/operator-pairs 
    104108   * array(field => array('value' => $value, 'operator' => $operator)) 
     
    108112   * @param array[array[string, string]] $columns 
    109113   */ 
    110   public function setFilter($fields); 
     114  public function addFilter($column, $value, $comparison = Criteria::EQUAL); 
    111115 
    112116  /** 
  • plugins/sfDataSourcePlugin/trunk/lib/sfDataSourcePropel.class.php

    r28753 r28788  
    386386   * @see sfDataSourceInterface 
    387387   */ 
    388   public function setFilter($fields) 
    389   { 
    390     throw new Exception('This method has not been implemented yet'); 
     388  // TODO: remove Criteria dependancy 
     389  public function addFilter($column, $value, $comparison = Criteria::EQUAL) 
     390  { 
     391    $this->requireColumn($column); 
     392 
     393    $query = $this->query; 
     394     
     395    // is you have a query object 
     396    if ($this->query) 
     397    { 
     398      // check if an objectPath has been given 
     399      $lastDot = strrpos($column, '.'); 
     400      if ($lastDot !== false) 
     401      { 
     402        // get the objectPath 
     403        $objectPath = substr($column, 0, $lastDot); 
     404         
     405        // and get Related Query Class 
     406        $strRelated = $query->translateObjectPathToAlias($objectPath); 
     407        $query = $query->useQuery($strRelated); 
     408        $column = substr($column, $lastDot + 1); 
     409      } 
     410    } 
     411     
     412    $query->filterBy($column, $value, $comparison);  
    391413  } 
    392414