ilter to the list of possible filters. * * @param string $name The name of the filter. * @param string $className The class name of the filter. */ public function addFilter($name, $className) { $this->_attributes['filters'][$name] = $className; } /** * Gets the class name for a given filter name. * * @param string $name The name of the filter. * * @return string|null The class name of the filter, or null if it is not * defined. * * @psalm-return ?class-string */ public function getFilterClassName($name) { return isset($this->_attributes['filters'][$name]) ? $this->_attributes['filters'][$name] : null; } /** * Sets default repository class. * * @since 2.2 * * @param string $className * * @return void * * @throws ORMException If $classname is not an ObjectRepository. */ public function setDefaultRepositoryClassName($className) { $reflectionClass = new \ReflectionClass($className); if ( ! $reflectionClass->implementsInterface(ObjectRepository::class)) { throw ORMException::invalidEntityRepository($className); } $this->_attributes['defaultRepositoryClassName'] = $className; } /** * Get default repository class. * * @since 2.2 * * @return string * * @psalm-return class-string */ public function getDefaultRepositoryClassName() { return isset($this->_attributes['defaultRepositoryClassName']) ? $this->_attributes['defaultRepositoryClassName'] : EntityRepository::class; } /** * Sets naming strategy. * * @since 2.3 * * @param NamingStrategy $namingStrategy * * @return void */ public function setNamingStrategy(NamingStrategy $namingStrategy) { $this->_attributes['namingStrategy'] = $namingStrategy; } /** * Gets naming strategy.. * * @since 2.3 * * @return NamingStrategy */ public function getNamingStrategy() { if ( ! isset($this->_attributes['namingStrategy'])) { $this->_attributes['namingStrategy'] = new DefaultNamingStrategy(); } return $this->_attributes['namingStrategy']; } /** * Sets quote strategy. * * @since 2.3 * * @param \Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy * * @return void */ public function setQuoteStrategy(QuoteStrategy $quoteStrategy) { $this->_attributes['quoteStrategy'] = $quoteStrategy; } /** * Gets quote strategy. * * @since 2.3 * * @return \Doctrine\ORM\Mapping\QuoteStrategy */ public function getQuoteStrategy() { if ( ! isset($this->_attributes['quoteStrategy'])) { $this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy(); } return $this->_attributes['quoteStrategy']; } /** * Set the entity listener resolver. * * @since 2.4 * @param \Doctrine\ORM\Mapping\EntityListenerResolver $resolver */ public function setEntityListenerResolver(EntityListenerResolver $resolver) { $this->_attributes['entityListenerResolver'] = $resolver; } /** * Get the entity listener resolver. * * @since 2.4 * @return \Doctrine\ORM\Mapping\EntityListenerResolver */ public function getEntityListenerResolver() { if ( ! isset($this->_attributes['entityListenerResolver'])) { $this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); } return $this->_attributes['entityListenerResolver']; } /** * Set the entity repository factory. * * @since 2.4 * @param \Doctrine\ORM\Repository\RepositoryFactory $repositoryFactory */ public function setRepositoryFactory(RepositoryFactory $repositoryFactory) { $this->_attributes['repositoryFactory'] = $repositoryFactory; } /** * Get the entity repository factory. * * @since 2.4 * @return \Doctrine\ORM\Repository\RepositoryFactory */ public function getRepositoryFactory() { return isset($this->_attributes['repositoryFactory']) ? $this->_attributes['repositoryFactory'] : new DefaultRepositoryFactory(); } /** * @since 2.5 * * @return boolean */ public function isSecondLevelCacheEnabled() { return isset($this->_attributes['isSecondLevelCacheEnabled']) ? $this->_attributes['isSecondLevelCacheEnabled'] : false; } /** * @since 2.5 * * @param boolean $flag * * @return void */ public function setSecondLevelCacheEnabled($flag = true) { $this->_attributes['isSecondLevelCacheEnabled'] = (boolean) $flag; } /** * @since 2.5 * * @param \Doctrine\ORM\Cache\CacheConfiguration $cacheConfig * * @return void */ public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig) { $this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig; } /** * @since 2.5 * * @return \Doctrine\ORM\Cache\CacheConfiguration|null */ public function getSecondLevelCacheConfiguration() { if ( ! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { $this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); } return isset($this->_attributes['secondLevelCacheConfiguration']) ? $this->_attributes['secondLevelCacheConfiguration'] : null; } /** * Returns query hints, which will be applied to every query in application * * @since 2.5 * * @return array */ public function getDefaultQueryHints() { return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : []; } /** * Sets array of query hints, which will be applied to every query in application * * @since 2.5 * * @param array $defaultQueryHints */ public function setDefaultQueryHints(array $defaultQueryHints) { $this->_attributes['defaultQueryHints'] = $defaultQueryHints; } /** * Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned. * * @since 2.5 * * @param string $name The name of the hint. * * @return mixed The value of the hint or FALSE, if the hint name is not recognized. */ public function getDefaultQueryHint($name) { return isset($this->_attributes['defaultQueryHints'][$name]) ? $this->_attributes['defaultQueryHints'][$name] : false; } /** * Sets a default query hint. If the hint name is not recognized, it is silently ignored. * * @since 2.5 * * @param string $name The name of the hint. * @param mixed $value The value of the hint. */ public function setDefaultQueryHint($name, $value) { $this->_attributes['defaultQueryHints'][$name] = $value; } } interface_exists(MappingDriver::class);