/** * 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 (null === ($filterClass = $this->config->getFilterClassName($name))) { throw new \InvalidArgumentException("Filter '" . $name . "' does not exist."); } if (!isset($this->enabledFilters[$name])) { $this->enabledFilters[$name] = new $filterClass($this->dm); } return $this->enabledFilters[$name]; }
/** * Checks whether filter with given name is defined. * * @param string $name Name of the filter. * @return bool true if the filter exists, false if not. */ public function has($name) { return null !== $this->config->getFilterClassName($name); }