/** * Enables a filter from the collection. * * @param string $name Name of the filter. * * @throws \InvalidArgumentException If the filter does not exist. * * @return \Doctrine\ORM\Query\Filter\SQLFilter The enabled filter. */ public function enable($name) { if (null === ($filter = $this->config->getFilter($name))) { throw new \InvalidArgumentException("Filter '" . $name . "' does not exist."); } if (!isset($this->enabledFilters[$name])) { $this->enabledFilters[$name] = is_object($filter) ? $filter : new $filter($this->em); // Keep the enabled filters sorted for the hash ksort($this->enabledFilters); // Now the filter collection is dirty $this->filtersState = self::FILTERS_STATE_DIRTY; } return $this->enabledFilters[$name]; }
public function testAddGetFilters() { $this->assertSame(null, $this->configuration->getFilter('NonExistingFilter')); $this->configuration->addFilter('FilterName', __CLASS__); $this->assertSame(__CLASS__, $this->configuration->getFilter('FilterName')); }