, ClassMetadata::GENERATOR_TYPE_*> */ private $identityGenerationPreferences = []; /** @psalm-param array, ClassMetadata::GENERATOR_TYPE_*> $value */ public function setIdentityGenerationPreferences(array $value): void { $this->identityGenerationPreferences = $value; } /** @psalm-return array, ClassMetadata::GENERATOR_TYPE_*> $value */ public function getIdentityGenerationPreferences(): array { return $this->identityGenerationPreferences; } /** * Sets the directory where Doctrine generates any necessary proxy class files. */ public function setProxyDir(string $dir): void { $this->attributes['proxyDir'] = $dir; } /** * Gets the directory where Doctrine generates any necessary proxy class files. */ public function getProxyDir(): string|null { return $this->attributes['proxyDir'] ?? null; } /** * Gets the strategy for automatically generating proxy classes. * * @return ProxyFactory::AUTOGENERATE_* */ public function getAutoGenerateProxyClasses(): int { return $this->attributes['autoGenerateProxyClasses'] ?? ProxyFactory::AUTOGENERATE_ALWAYS; } /** * Sets the strategy for automatically generating proxy classes. * * @param bool|ProxyFactory::AUTOGENERATE_* $autoGenerate True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER. */ public function setAutoGenerateProxyClasses(bool|int $autoGenerate): void { $this->attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; } /** * Gets the namespace where proxy classes reside. */ public function getProxyNamespace(): string|null { return $this->attributes['proxyNamespace'] ?? null; } /** * Sets the namespace where proxy classes reside. */ public function setProxyNamespace(string $ns): void { $this->attributes['proxyNamespace'] = $ns; } /** * Sets the cache driver implementation that is used for metadata caching. * * @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): void { $this->attributes['metadataDriverImpl'] = $driverImpl; } /** * Sets the entity alias map. * * @psalm-param array $entityNamespaces */ public function setEntityNamespaces(array $entityNamespaces): void { $this->attributes['entityNamespaces'] = $entityNamespaces; } /** * Retrieves the list of registered entity namespace aliases. * * @psalm-return array */ public function getEntityNamespaces(): array { return $this->attributes['entityNamespaces']; } /** * Gets the cache driver implementation that is used for the mapping metadata. */ public function getMetadataDriverImpl(): MappingDriver|null { return $this->attributes['metadataDriverImpl'] ?? null; } /** * Gets the cache driver implementation that is used for the query cache (SQL cache). */ public function getQueryCache(): CacheItemPoolInterface|null { return $this->attributes['queryCache'] ?? null; } /** * Sets the cache driver implementation that is used for the query cache (SQL cache). */ public function setQueryCache(CacheItemPoolInterface $cache): void { $this->attributes['queryCache'] = $cache; } public function getHydrationCache(): CacheItemPoolInterface|null { return $this->attributes['hydrationCache'] ?? null; } public function setHydrationCache(CacheItemPoolInterface $cache): void { $this->attributes['hydrationCache'] = $cache; } public function getMetadataCache(): CacheItemPoolInterface|null { return $this->attributes['metadataCache'] ?? null; } public function setMetadataCache(CacheItemPoolInterface $cache): void { $this->attributes['metadataCache'] = $cache; } /** * 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 class-string|callable $className Class name or a callable that returns the function. * @psalm-param class-string|callable(string):FunctionNode $className */ public function addCustomStringFunction(string $name, string|callable $className): void { $this->attributes['customStringFunctions'][strtolower($name)] = $className; } /** * Gets the implementation class name of a registered custom string DQL function. * * @psalm-return class-string|callable(string):FunctionNode|null */ public function getCustomStringFunction(string $name): string|callable|null { $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. * * @psalm-param array|callable(string):FunctionNode> $functions The map of custom * DQL string functions. */ public function setCustomStringFunctions(array $functions): void { 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 class-string|callable $className Class name or a callable that returns the function. * @psalm-param class-string|callable(string):FunctionNode $className */ public function addCustomNumericFunction(string $name, string|callable $className): void { $this->attributes['customNumericFunctions'][strtolower($name)] = $className; } /** * Gets the implementation class name of a registered custom numeric DQL function. * * @psalm-return ?class-string|callable(string):FunctionNode */ public function getCustomNumericFunction(string $name): string|callable|null { $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. * * @psalm-param array $functions The map of custom * DQL numeric functions. */ public function setCustomNumericFunctions(array $functions): void { 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|callable $className Class name or a callable that returns the function. * @psalm-param class-string|callable(string):FunctionNode $className */ public function addCustomDatetimeFunction(string $name, string|callable $className): void { $this->attributes['customDatetimeFunctions'][strtolower($name)] = $className; } /** * Gets the implementation class name of a registered custom date/time DQL function. * * @psalm-return class-string|callable|null */ public function getCustomDatetimeFunction(string $name): string|callable|null { $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. * @psalm-param array|callable(string):FunctionNode> $functions */ public function setCustomDatetimeFunctions(array $functions): void { foreach ($functions as $name => $className) { $this->addCustomDatetimeFunction($name, $className); } } /** * Sets a TypedFieldMapper for php typed fields to DBAL types auto-completion. */ public function setTypedFieldMapper(TypedFieldMapper|null $typedFieldMapper): void { $this->attributes['typedFieldMapper'] = $typedFieldMapper; } /** * Gets a TypedFieldMapper for php typed fields to DBAL types auto-completion. */ public function getTypedFieldMapper(): TypedFieldMapper|null { return $this->attributes['typedFieldMapper'] ?? null; } /** * Sets the custom hydrator modes in one pass. * * @param array> $modes An array of ($modeName => $hydrator). */ public function setCustomHydrationModes(array $modes): void { $this->attributes['customHydrationModes'] = []; foreach ($modes as $modeName => $hydrator) { $this->addCustomHydrationMode($modeName, $hydrator); } } /** * Gets the hydrator class for the given hydration mode name. * * @psalm-return class-string|null */ public function getCustomHydrationMode(string $modeName): string|null { return $this->attributes['customHydrationModes'][$modeName] ?? null; } /** * Adds a custom hydration mode. * * @psalm-param class-string $hydrator */ public function addCustomHydrationMode(string $modeName, string $hydrator): void { $this->attributes['customHydrationModes'][$modeName] = $hydrator; } /** * Sets a class metadata factory. * * @psalm-param class-string $cmfName */ public function setClassMetadataFactoryName(string $cmfName): void { $this->attributes['classMetadataFactoryName'] = $cmfName; } /** @psalm-return class-string */ public function getClassMetadataFactoryName(): string { 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 $className The class name of the filter. * @psalm-param class-string $className */ public function addFilter(string $name, string $className): void { $this->attributes['filters'][$name] = $className; } /** * Gets the class name for a given filter name. * * @return string|null The class name of the filter, or null if it is not * defined. * @psalm-return class-string|null */ public function getFilterClassName(string $name): string|null { return $this->attributes['filters'][$name] ?? null; } /** * Sets default repository class. * * @psalm-param class-string $className * * @throws InvalidEntityRepository If $classname is not an ObjectRepository. */ public function setDefaultRepositoryClassName(string $className): void { if (! class_exists($className) || ! is_a($className, EntityRepository::class, true)) { throw InvalidEntityRepository::fromClassName($className); } $this->attributes['defaultRepositoryClassName'] = $className; } /** * Get default repository class. * * @psalm-return class-string */ public function getDefaultRepositoryClassName(): string { return $this->attributes['defaultRepositoryClassName'] ?? EntityRepository::class; } /** * Sets naming strategy. */ public function setNamingStrategy(NamingStrategy $namingStrategy): void { $this->attributes['namingStrategy'] = $namingStrategy; } /** * Gets naming strategy.. */ public function getNamingStrategy(): NamingStrategy { if (! isset($this->attributes['namingStrategy'])) { $this->attributes['namingStrategy'] = new DefaultNamingStrategy(); } return $this->attributes['namingStrategy']; } /** * Sets quote strategy. */ public function setQuoteStrategy(QuoteStrategy $quoteStrategy): void { $this->attributes['quoteStrategy'] = $quoteStrategy; } /** * Gets quote strategy. */ public function getQuoteStrategy(): QuoteStrategy { if (! isset($this->attributes['quoteStrategy'])) { $this->attributes['quoteStrategy'] = new DefaultQuoteStrategy(); } return $this->attributes['quoteStrategy']; } /** * Set the entity listener resolver. */ public function setEntityListenerResolver(EntityListenerResolver $resolver): void { $this->attributes['entityListenerResolver'] = $resolver; } /** * Get the entity listener resolver. */ public function getEntityListenerResolver(): EntityListenerResolver { if (! isset($this->attributes['entityListenerResolver'])) { $this->attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); } return $this->attributes['entityListenerResolver']; } /** * Set the entity repository factory. */ public function setRepositoryFactory(RepositoryFactory $repositoryFactory): void { $this->attributes['repositoryFactory'] = $repositoryFactory; } /** * Get the entity repository factory. */ public function getRepositoryFactory(): RepositoryFactory { return $this->attributes['repositoryFactory'] ?? new DefaultRepositoryFactory(); } public function isSecondLevelCacheEnabled(): bool { return $this->attributes['isSecondLevelCacheEnabled'] ?? false; } public function setSecondLevelCacheEnabled(bool $flag = true): void { $this->attributes['isSecondLevelCacheEnabled'] = $flag; } public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig): void { $this->attributes['secondLevelCacheConfiguration'] = $cacheConfig; } public function getSecondLevelCacheConfiguration(): CacheConfiguration|null { 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 */ public function getDefaultQueryHints(): array { return $this->attributes['defaultQueryHints'] ?? []; } /** * Sets array of query hints, which will be applied to every query in application * * @psalm-param array $defaultQueryHints */ public function setDefaultQueryHints(array $defaultQueryHints): void { $this->attributes['defaultQueryHints'] = $defaultQueryHints; } /** * Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned. * * @return mixed The value of the hint or FALSE, if the hint name is not recognized. */ public function getDefaultQueryHint(string $name): mixed { return $this->attributes['defaultQueryHints'][$name] ?? false; } /** * Sets a default query hint. If the hint name is not recognized, it is silently ignored. */ public function setDefaultQueryHint(string $name, mixed $value): void { $this->attributes['defaultQueryHints'][$name] = $value; } /** * Gets a list of entity class names to be ignored by the SchemaTool * * @return list */ public function getSchemaIgnoreClasses(): array { return $this->attributes['schemaIgnoreClasses'] ?? []; } /** * Sets a list of entity class names to be ignored by the SchemaTool * * @param list $schemaIgnoreClasses List of entity class names */ public function setSchemaIgnoreClasses(array $schemaIgnoreClasses): void { $this->attributes['schemaIgnoreClasses'] = $schemaIgnoreClasses; } /** * To be deprecated in 3.1.0 * * @return true */ public function isLazyGhostObjectEnabled(): bool { return true; } /** To be deprecated in 3.1.0 */ public function setLazyGhostObjectEnabled(bool $flag): void { if (! $flag) { throw new LogicException(<<<'EXCEPTION' The lazy ghost object feature cannot be disabled anymore. Please remove the call to setLazyGhostObjectEnabled(false). EXCEPTION); } } /** To be deprecated in 3.1.0 */ public function setRejectIdCollisionInIdentityMap(bool $flag): void { if (! $flag) { throw new LogicException(<<<'EXCEPTION' Rejecting ID collisions in the identity map cannot be disabled anymore. Please remove the call to setRejectIdCollisionInIdentityMap(false). EXCEPTION); } } /** * To be deprecated in 3.1.0 * * @return true */ public function isRejectIdCollisionInIdentityMapEnabled(): bool { return true; } public function setEagerFetchBatchSize(int $batchSize = 100): void { $this->attributes['fetchModeSubselectBatchSize'] = $batchSize; } public function getEagerFetchBatchSize(): int { return $this->attributes['fetchModeSubselectBatchSize'] ?? 100; } }