Exemplo n.º 1
0
 /**
  * Apply filter to collection
  *
  * @param CollectionFilter $filter
  *
  * @return Collection
  */
 public function applyFilter(CollectionFilter $filter)
 {
     $filterExpression = $filter->getFilterExpression();
     if ($filterExpression instanceof ExpressionInterface && !$filterExpression->isEmpty()) {
         $this->getDataSource()->whereEx($filterExpression);
         return $this;
     }
     /**
      * For backward compatibility
      * @todo remove this and migrate to new expression filter
      */
     foreach ($filter->getFilterMethods() as $method) {
         $statement = $method['statement'];
         $field = $method['field'];
         $value = $method['value'];
         $this->getDataSource()->{$statement}($field, $value);
     }
     return $this;
 }