/**
  * @param array $filters
  * @throws \Searchperience\Common\Exception\UnexpectedValueException
  * @return FilterCollection
  */
 public function createFromFilterArguments($filters)
 {
     if (!$this->validateFilterArguments($filters)) {
         throw new \Searchperience\Common\Exception\UnexpectedValueException('');
     }
     $result = new FilterCollection();
     foreach ($filters as $filterName => $filterValue) {
         $filterName = ucfirst($filterName);
         $filterClassName = $this->getFilterClassName($filterName);
         if (class_exists($filterClassName)) {
             $filter = $this->initFilter($filterClassName, $filterValue);
             $result->addFilter($filter);
         } else {
             throw new \Searchperience\Common\Exception\UnexpectedValueException('Filter not exists: ' . $filterName);
         }
     }
     return $result;
 }
Beispiel #2
0
 /**
  * Add a filter to the filter-list
  *
  * @param \Converter\FilterInterface $filter
  *
  * @return void
  */
 public function addFilter(FilterInterface $filter)
 {
     $this->filters->addFilter($filter);
 }