DMS\Bundle\FilterBundle\Filter\ContainerFilter::apply PHP Method

apply() public method

Enforces the desired filtering on the the value returning a filtered value.
public apply ( Rule $rule, mixed $value ) : mixed
$rule DMS\Filter\Rules\Rule
$value mixed
return mixed
    public function apply(Rule $rule, $value)
    {
        if (!$this->container->has($rule->service)) {
            throw new \Exception("Unable to find service '{$rule->service}' to execute defined rule.");
        }
        $service = $this->container->get($rule->service);
        if (!method_exists($service, $rule->method)) {
            throw new \Exception("Unable to find the method '{$rule->method}' in service '{$rule->service}'.");
        }
        $method = $rule->method;
        return $service->{$method}($value);
    }
ContainerFilter