/** * Enables a filter from the collection. * * @param string $name Name of the filter. * * @throws \InvalidArgumentException If the filter does not exist. * * @return \Doctrine\ODM\MongoDB\Query\Filter\BsonFilter The enabled filter. */ public function enable($name) { if (!$this->has($name)) { throw new \InvalidArgumentException("Filter '" . $name . "' does not exist."); } if (!$this->isEnabled($name)) { $filterClass = $this->config->getFilterClassName($name); $filterParameters = $this->config->getFilterParameters($name); $filter = new $filterClass($this->dm); foreach ($filterParameters as $param => $value) { $filter->setParameter($param, $value); } $this->enabledFilters[$name] = $filter; } return $this->enabledFilters[$name]; }