Defines the required interface for a loader capable of finding the executor of a specific rule.
Example #1
0
 /**
  * Applies a Filtering Rule to a property
  *
  * @param string $property
  * @param Rules\Rule $filterRule
  *
  * @throws \UnexpectedValueException
  */
 public function applyFilterRule($property, Rules\Rule $filterRule)
 {
     if ($this->filterLoader === null) {
         throw new \UnexpectedValueException("A FilterLoader must be provided");
     }
     $value = $this->getPropertyValue($property);
     $filter = $this->filterLoader->getFilterForRule($filterRule);
     if ($filter instanceof ObjectAwareFilter) {
         $filter->setCurrentObject($this->object);
     }
     $filteredValue = $filter->apply($filterRule, $value);
     $this->setPropertyValue($property, $filteredValue);
 }
Example #2
0
 /**
  * Iterates over an array of filters applying all to the value
  *
  * @param mixed $value
  * @param array $rules
  * @return mixed
  */
 protected function walkRuleChain($value, $rules)
 {
     foreach ($rules as $rule) {
         $filter = $this->filterLoader->getFilterForRule($rule);
         $value = $filter->apply($rule, $value);
     }
     return $value;
 }