示例#1
0
 /**
  * Binds form data to filters, and then adds those filters to a new instance of FilterCollection,
  * discarding the original and any filters that do not have values
  *
  * @param array $data
  * @param FilterCollection $filters
  *
  * @return FilterCollection
  */
 public function bindData(array $data, FilterCollection $filters)
 {
     $boundFilters = new FilterCollection();
     foreach ($data as $key => $value) {
         if ($filters->exists($key) && $value) {
             $filter = $filters[$key];
             $filter->setValue($value);
             $boundFilters->add($filter);
         }
     }
     return $boundFilters;
 }