123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866 |
- <?php
- /*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the MIT license. For more information, see
- * <http://www.doctrine-project.org>.
- */
- namespace Doctrine\ORM;
- use Doctrine\Common\Annotations\AnnotationReader;
- use Doctrine\Common\Annotations\AnnotationRegistry;
- use Doctrine\Common\Annotations\CachedReader;
- use Doctrine\Common\Annotations\SimpleAnnotationReader;
- use Doctrine\Common\Cache\ArrayCache;
- use Doctrine\Common\Cache\Cache as CacheDriver;
- use Doctrine\Common\Proxy\AbstractProxyFactory;
- use Doctrine\ORM\Cache\CacheConfiguration;
- use Doctrine\ORM\Mapping\ClassMetadataFactory;
- use Doctrine\ORM\Mapping\DefaultEntityListenerResolver;
- use Doctrine\ORM\Mapping\DefaultNamingStrategy;
- use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
- use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
- use Doctrine\ORM\Mapping\EntityListenerResolver;
- use Doctrine\ORM\Mapping\NamingStrategy;
- use Doctrine\ORM\Mapping\QuoteStrategy;
- use Doctrine\ORM\Query\ResultSetMapping;
- use Doctrine\ORM\Repository\DefaultRepositoryFactory;
- use Doctrine\ORM\Repository\RepositoryFactory;
- use Doctrine\Persistence\Mapping\Driver\MappingDriver;
- use Doctrine\Persistence\ObjectRepository;
- use ReflectionClass;
- use function strtolower;
- use function trim;
- /**
- * Configuration container for all configuration options of Doctrine.
- * It combines all configuration options from DBAL & ORM.
- *
- * Internal note: When adding a new configuration option just write a getter/setter pair.
- */
- class Configuration extends \Doctrine\DBAL\Configuration
- {
- /**
- * Sets the directory where Doctrine generates any necessary proxy class files.
- *
- * @param string $dir
- *
- * @return void
- */
- public function setProxyDir($dir)
- {
- $this->_attributes['proxyDir'] = $dir;
- }
- /**
- * Gets the directory where Doctrine generates any necessary proxy class files.
- *
- * @deprecated 2.7 We're switch to `ocramius/proxy-manager` and this method isn't applicable any longer
- *
- * @see https://github.com/Ocramius/ProxyManager
- *
- * @return string|null
- */
- public function getProxyDir()
- {
- return $this->_attributes['proxyDir'] ?? null;
- }
- /**
- * Gets the strategy for automatically generating proxy classes.
- *
- * @deprecated 2.7 We're switch to `ocramius/proxy-manager` and this method isn't applicable any longer
- *
- * @see https://github.com/Ocramius/ProxyManager
- *
- * @return int Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory.
- */
- public function getAutoGenerateProxyClasses()
- {
- return $this->_attributes['autoGenerateProxyClasses'] ?? AbstractProxyFactory::AUTOGENERATE_ALWAYS;
- }
- /**
- * Sets the strategy for automatically generating proxy classes.
- *
- * @param bool|int $autoGenerate Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory.
- * True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER.
- *
- * @return void
- */
- public function setAutoGenerateProxyClasses($autoGenerate)
- {
- $this->_attributes['autoGenerateProxyClasses'] = (int) $autoGenerate;
- }
- /**
- * Gets the namespace where proxy classes reside.
- *
- * @deprecated 2.7 We're switch to `ocramius/proxy-manager` and this method isn't applicable any longer
- *
- * @see https://github.com/Ocramius/ProxyManager
- *
- * @return string|null
- */
- public function getProxyNamespace()
- {
- return $this->_attributes['proxyNamespace'] ?? null;
- }
- /**
- * Sets the namespace where proxy classes reside.
- *
- * @param string $ns
- *
- * @return void
- */
- public function setProxyNamespace($ns)
- {
- $this->_attributes['proxyNamespace'] = $ns;
- }
- /**
- * Sets the cache driver implementation that is used for metadata caching.
- *
- * @return void
- *
- * @todo Force parameter to be a Closure to ensure lazy evaluation
- * (as soon as a metadata cache is in effect, the driver never needs to initialize).
- */
- public function setMetadataDriverImpl(MappingDriver $driverImpl)
- {
- $this->_attributes['metadataDriverImpl'] = $driverImpl;
- }
- /**
- * Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader
- * is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.
- *
- * @param bool $useSimpleAnnotationReader
- *
- * @return AnnotationDriver
- *
- * @psalm-param string|list<string> $paths
- */
- public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
- {
- AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
- if ($useSimpleAnnotationReader) {
- // Register the ORM Annotations in the AnnotationRegistry
- $reader = new SimpleAnnotationReader();
- $reader->addNamespace('Doctrine\ORM\Mapping');
- $cachedReader = new CachedReader($reader, new ArrayCache());
- return new AnnotationDriver($cachedReader, (array) $paths);
- }
- return new AnnotationDriver(
- new CachedReader(new AnnotationReader(), new ArrayCache()),
- (array) $paths
- );
- }
- /**
- * Adds a namespace under a certain alias.
- *
- * @param string $alias
- * @param string $namespace
- *
- * @return void
- */
- public function addEntityNamespace($alias, $namespace)
- {
- $this->_attributes['entityNamespaces'][$alias] = $namespace;
- }
- /**
- * Resolves a registered namespace alias to the full namespace.
- *
- * @param string $entityNamespaceAlias
- *
- * @return string
- *
- * @throws ORMException
- */
- public function getEntityNamespace($entityNamespaceAlias)
- {
- if (! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) {
- throw ORMException::unknownEntityNamespace($entityNamespaceAlias);
- }
- return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\');
- }
- /**
- * Sets the entity alias map.
- *
- * @return void
- *
- * @psalm-param array<string, string> $entityNamespaces
- */
- public function setEntityNamespaces(array $entityNamespaces)
- {
- $this->_attributes['entityNamespaces'] = $entityNamespaces;
- }
- /**
- * Retrieves the list of registered entity namespace aliases.
- *
- * @psalm-return array<string, string>
- */
- public function getEntityNamespaces()
- {
- return $this->_attributes['entityNamespaces'];
- }
- /**
- * Gets the cache driver implementation that is used for the mapping metadata.
- *
- * @return MappingDriver|null
- *
- * @throws ORMException
- */
- public function getMetadataDriverImpl()
- {
- return $this->_attributes['metadataDriverImpl'] ?? null;
- }
- /**
- * Gets the cache driver implementation that is used for the query cache (SQL cache).
- *
- * @return CacheDriver|null
- */
- public function getQueryCacheImpl()
- {
- return $this->_attributes['queryCacheImpl'] ?? null;
- }
- /**
- * Sets the cache driver implementation that is used for the query cache (SQL cache).
- *
- * @return void
- */
- public function setQueryCacheImpl(CacheDriver $cacheImpl)
- {
- $this->_attributes['queryCacheImpl'] = $cacheImpl;
- }
- /**
- * Gets the cache driver implementation that is used for the hydration cache (SQL cache).
- *
- * @return CacheDriver|null
- */
- public function getHydrationCacheImpl()
- {
- return $this->_attributes['hydrationCacheImpl'] ?? null;
- }
- /**
- * Sets the cache driver implementation that is used for the hydration cache (SQL cache).
- *
- * @return void
- */
- public function setHydrationCacheImpl(CacheDriver $cacheImpl)
- {
- $this->_attributes['hydrationCacheImpl'] = $cacheImpl;
- }
- /**
- * Gets the cache driver implementation that is used for metadata caching.
- *
- * @return CacheDriver|null
- */
- public function getMetadataCacheImpl()
- {
- return $this->_attributes['metadataCacheImpl'] ?? null;
- }
- /**
- * Sets the cache driver implementation that is used for metadata caching.
- *
- * @return void
- */
- public function setMetadataCacheImpl(CacheDriver $cacheImpl)
- {
- $this->_attributes['metadataCacheImpl'] = $cacheImpl;
- }
- /**
- * Adds a named DQL query to the configuration.
- *
- * @param string $name The name of the query.
- * @param string $dql The DQL query string.
- *
- * @return void
- */
- public function addNamedQuery($name, $dql)
- {
- $this->_attributes['namedQueries'][$name] = $dql;
- }
- /**
- * Gets a previously registered named DQL query.
- *
- * @param string $name The name of the query.
- *
- * @return string The DQL query.
- *
- * @throws ORMException
- */
- public function getNamedQuery($name)
- {
- if (! isset($this->_attributes['namedQueries'][$name])) {
- throw ORMException::namedQueryNotFound($name);
- }
- return $this->_attributes['namedQueries'][$name];
- }
- /**
- * Adds a named native query to the configuration.
- *
- * @param string $name The name of the query.
- * @param string $sql The native SQL query string.
- * @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query.
- *
- * @return void
- */
- public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
- {
- $this->_attributes['namedNativeQueries'][$name] = [$sql, $rsm];
- }
- /**
- * Gets the components of a previously registered named native query.
- *
- * @param string $name The name of the query.
- *
- * @throws ORMException
- *
- * @psalm-return array{string, ResultSetMapping} A tuple with the first
- * element being the SQL
- * string and the second
- * element being the
- * ResultSetMapping.
- */
- public function getNamedNativeQuery($name)
- {
- if (! isset($this->_attributes['namedNativeQueries'][$name])) {
- throw ORMException::namedNativeQueryNotFound($name);
- }
- return $this->_attributes['namedNativeQueries'][$name];
- }
- /**
- * Ensures that this Configuration instance contains settings that are
- * suitable for a production environment.
- *
- * @return void
- *
- * @throws ORMException If a configuration setting has a value that is not
- * suitable for a production environment.
- */
- public function ensureProductionSettings()
- {
- $queryCacheImpl = $this->getQueryCacheImpl();
- if (! $queryCacheImpl) {
- throw ORMException::queryCacheNotConfigured();
- }
- if ($queryCacheImpl instanceof ArrayCache) {
- throw ORMException::queryCacheUsesNonPersistentCache($queryCacheImpl);
- }
- $metadataCacheImpl = $this->getMetadataCacheImpl();
- if (! $metadataCacheImpl) {
- throw ORMException::metadataCacheNotConfigured();
- }
- if ($metadataCacheImpl instanceof ArrayCache) {
- throw ORMException::metadataCacheUsesNonPersistentCache($metadataCacheImpl);
- }
- if ($this->getAutoGenerateProxyClasses()) {
- throw ORMException::proxyClassesAlwaysRegenerating();
- }
- }
- /**
- * Registers a custom DQL function that produces a string value.
- * Such a function can then be used in any DQL statement in any place where string
- * functions are allowed.
- *
- * DQL function names are case-insensitive.
- *
- * @param string $name Function name.
- * @param string|callable $className Class name or a callable that returns the function.
- *
- * @return void
- */
- public function addCustomStringFunction($name, $className)
- {
- $this->_attributes['customStringFunctions'][strtolower($name)] = $className;
- }
- /**
- * Gets the implementation class name of a registered custom string DQL function.
- *
- * @param string $name
- *
- * @return string|null
- *
- * @psalm-return ?class-string
- */
- public function getCustomStringFunction($name)
- {
- $name = strtolower($name);
- return $this->_attributes['customStringFunctions'][$name] ?? null;
- }
- /**
- * Sets a map of custom DQL string functions.
- *
- * Keys must be function names and values the FQCN of the implementing class.
- * The function names will be case-insensitive in DQL.
- *
- * Any previously added string functions are discarded.
- *
- * @return void
- *
- * @psalm-param array<string, class-string> $functions The map of custom
- * DQL string functions.
- */
- public function setCustomStringFunctions(array $functions)
- {
- foreach ($functions as $name => $className) {
- $this->addCustomStringFunction($name, $className);
- }
- }
- /**
- * Registers a custom DQL function that produces a numeric value.
- * Such a function can then be used in any DQL statement in any place where numeric
- * functions are allowed.
- *
- * DQL function names are case-insensitive.
- *
- * @param string $name Function name.
- * @param string|callable $className Class name or a callable that returns the function.
- *
- * @return void
- */
- public function addCustomNumericFunction($name, $className)
- {
- $this->_attributes['customNumericFunctions'][strtolower($name)] = $className;
- }
- /**
- * Gets the implementation class name of a registered custom numeric DQL function.
- *
- * @param string $name
- *
- * @return string|null
- *
- * @psalm-return ?class-string
- */
- public function getCustomNumericFunction($name)
- {
- $name = strtolower($name);
- return $this->_attributes['customNumericFunctions'][$name] ?? null;
- }
- /**
- * Sets a map of custom DQL numeric functions.
- *
- * Keys must be function names and values the FQCN of the implementing class.
- * The function names will be case-insensitive in DQL.
- *
- * Any previously added numeric functions are discarded.
- *
- * @return void
- *
- * @psalm-param array<string, class-string> $functions The map of custom
- * DQL numeric functions.
- */
- public function setCustomNumericFunctions(array $functions)
- {
- foreach ($functions as $name => $className) {
- $this->addCustomNumericFunction($name, $className);
- }
- }
- /**
- * Registers a custom DQL function that produces a date/time value.
- * Such a function can then be used in any DQL statement in any place where date/time
- * functions are allowed.
- *
- * DQL function names are case-insensitive.
- *
- * @param string $name Function name.
- * @param string|callable $className Class name or a callable that returns the function.
- *
- * @return void
- *
- * @psalm-param class-string|callable $className
- */
- public function addCustomDatetimeFunction($name, $className)
- {
- $this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className;
- }
- /**
- * Gets the implementation class name of a registered custom date/time DQL function.
- *
- * @param string $name
- *
- * @return string|null
- *
- * @psalm-return ?class-string $name
- */
- public function getCustomDatetimeFunction($name)
- {
- $name = strtolower($name);
- return $this->_attributes['customDatetimeFunctions'][$name] ?? null;
- }
- /**
- * Sets a map of custom DQL date/time functions.
- *
- * Keys must be function names and values the FQCN of the implementing class.
- * The function names will be case-insensitive in DQL.
- *
- * Any previously added date/time functions are discarded.
- *
- * @param array $functions The map of custom DQL date/time functions.
- *
- * @return void
- *
- * @psalm-param array<string, string> $functions
- */
- public function setCustomDatetimeFunctions(array $functions)
- {
- foreach ($functions as $name => $className) {
- $this->addCustomDatetimeFunction($name, $className);
- }
- }
- /**
- * Sets the custom hydrator modes in one pass.
- *
- * @param array<string, class-string> $modes An array of ($modeName => $hydrator).
- *
- * @return void
- */
- public function setCustomHydrationModes($modes)
- {
- $this->_attributes['customHydrationModes'] = [];
- foreach ($modes as $modeName => $hydrator) {
- $this->addCustomHydrationMode($modeName, $hydrator);
- }
- }
- /**
- * Gets the hydrator class for the given hydration mode name.
- *
- * @param string $modeName The hydration mode name.
- *
- * @return string|null The hydrator class name.
- *
- * @psalm-return ?class-string
- */
- public function getCustomHydrationMode($modeName)
- {
- return $this->_attributes['customHydrationModes'][$modeName] ?? null;
- }
- /**
- * Adds a custom hydration mode.
- *
- * @param string $modeName The hydration mode name.
- *
- * @return void
- *
- * @psalm-param class-string $hydrator The hydrator class name.
- */
- public function addCustomHydrationMode($modeName, $hydrator)
- {
- $this->_attributes['customHydrationModes'][$modeName] = $hydrator;
- }
- /**
- * Sets a class metadata factory.
- *
- * @param string $cmfName
- *
- * @return void
- *
- * @psalm-param class-string $cmfName
- */
- public function setClassMetadataFactoryName($cmfName)
- {
- $this->_attributes['classMetadataFactoryName'] = $cmfName;
- }
- /**
- * @return string
- *
- * @psalm-return class-string
- */
- public function getClassMetadataFactoryName()
- {
- if (! isset($this->_attributes['classMetadataFactoryName'])) {
- $this->_attributes['classMetadataFactoryName'] = ClassMetadataFactory::class;
- }
- return $this->_attributes['classMetadataFactoryName'];
- }
- /**
- * Adds a filter 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 $this->_attributes['filters'][$name] ?? null;
- }
- /**
- * Sets default repository class.
- *
- * @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.
- *
- * @return string
- *
- * @psalm-return class-string
- */
- public function getDefaultRepositoryClassName()
- {
- return $this->_attributes['defaultRepositoryClassName'] ?? EntityRepository::class;
- }
- /**
- * Sets naming strategy.
- *
- * @return void
- */
- public function setNamingStrategy(NamingStrategy $namingStrategy)
- {
- $this->_attributes['namingStrategy'] = $namingStrategy;
- }
- /**
- * Gets naming strategy..
- *
- * @return NamingStrategy
- */
- public function getNamingStrategy()
- {
- if (! isset($this->_attributes['namingStrategy'])) {
- $this->_attributes['namingStrategy'] = new DefaultNamingStrategy();
- }
- return $this->_attributes['namingStrategy'];
- }
- /**
- * Sets quote strategy.
- *
- * @return void
- */
- public function setQuoteStrategy(QuoteStrategy $quoteStrategy)
- {
- $this->_attributes['quoteStrategy'] = $quoteStrategy;
- }
- /**
- * Gets quote strategy.
- *
- * @return QuoteStrategy
- */
- public function getQuoteStrategy()
- {
- if (! isset($this->_attributes['quoteStrategy'])) {
- $this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy();
- }
- return $this->_attributes['quoteStrategy'];
- }
- /**
- * Set the entity listener resolver.
- */
- public function setEntityListenerResolver(EntityListenerResolver $resolver)
- {
- $this->_attributes['entityListenerResolver'] = $resolver;
- }
- /**
- * Get the entity listener resolver.
- *
- * @return EntityListenerResolver
- */
- public function getEntityListenerResolver()
- {
- if (! isset($this->_attributes['entityListenerResolver'])) {
- $this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver();
- }
- return $this->_attributes['entityListenerResolver'];
- }
- /**
- * Set the entity repository factory.
- */
- public function setRepositoryFactory(RepositoryFactory $repositoryFactory)
- {
- $this->_attributes['repositoryFactory'] = $repositoryFactory;
- }
- /**
- * Get the entity repository factory.
- *
- * @return RepositoryFactory
- */
- public function getRepositoryFactory()
- {
- return $this->_attributes['repositoryFactory'] ?? new DefaultRepositoryFactory();
- }
- /**
- * @return bool
- */
- public function isSecondLevelCacheEnabled()
- {
- return $this->_attributes['isSecondLevelCacheEnabled'] ?? false;
- }
- /**
- * @param bool $flag
- *
- * @return void
- */
- public function setSecondLevelCacheEnabled($flag = true)
- {
- $this->_attributes['isSecondLevelCacheEnabled'] = (bool) $flag;
- }
- /**
- * @return void
- */
- public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig)
- {
- $this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig;
- }
- /**
- * @return CacheConfiguration|null
- */
- public function getSecondLevelCacheConfiguration()
- {
- if (! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) {
- $this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration();
- }
- return $this->_attributes['secondLevelCacheConfiguration'] ?? null;
- }
- /**
- * Returns query hints, which will be applied to every query in application
- *
- * @psalm-return array<string, mixed>
- */
- public function getDefaultQueryHints()
- {
- return $this->_attributes['defaultQueryHints'] ?? [];
- }
- /**
- * Sets array of query hints, which will be applied to every query in application
- *
- * @psalm-param array<string, mixed> $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.
- *
- * @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 $this->_attributes['defaultQueryHints'][$name] ?? false;
- }
- /**
- * Sets a default query hint. If the hint name is not recognized, it is silently ignored.
- *
- * @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;
- }
- }
|