Exemplo n.º 1
0
 public function apply(App_ListFilter $filterlist)
 {
     if (!($fieldName = $this->getFieldName())) {
         throw new App_ListFilter_Rule_Condition_Exception("Filter field name not defined.");
     }
     $filterName = $this->getFilterField();
     if ($scopeVar = $this->getFromScopeVar()) {
         $filters = $filterlist->getFromScope($scopeVar);
         if (!is_array($filters)) {
             $filters = array($filters);
         }
     } else {
         $filters = $filterlist->getFiltersByFieldName($filterName);
     }
     foreach ($filters as $filter) {
         if (($class = $this->getFilterClass()) && !$filter instanceof $class) {
             continue;
         }
         if ($filterName && $filter->getFieldName() != $filterName) {
             continue;
         }
         if ($this->_checkValue($filter->{'get' . ucfirst($this->getFieldName())}(), $this->getComparedValue())) {
             if ($this->getScopeVar()) {
                 $filterlist->addToScope($this->getScopeVar(), $filter);
             }
             return true;
         }
     }
     return false;
 }