diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Configuration.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Configuration.php')
| -rw-r--r-- | vendor/doctrine/orm/src/Configuration.php | 649 |
1 files changed, 649 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Configuration.php b/vendor/doctrine/orm/src/Configuration.php new file mode 100644 index 0000000..b30764e --- /dev/null +++ b/vendor/doctrine/orm/src/Configuration.php | |||
| @@ -0,0 +1,649 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
| 8 | use Doctrine\ORM\Cache\CacheConfiguration; | ||
| 9 | use Doctrine\ORM\Exception\InvalidEntityRepository; | ||
| 10 | use Doctrine\ORM\Internal\Hydration\AbstractHydrator; | ||
| 11 | use Doctrine\ORM\Mapping\ClassMetadata; | ||
| 12 | use Doctrine\ORM\Mapping\ClassMetadataFactory; | ||
| 13 | use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; | ||
| 14 | use Doctrine\ORM\Mapping\DefaultNamingStrategy; | ||
| 15 | use Doctrine\ORM\Mapping\DefaultQuoteStrategy; | ||
| 16 | use Doctrine\ORM\Mapping\EntityListenerResolver; | ||
| 17 | use Doctrine\ORM\Mapping\NamingStrategy; | ||
| 18 | use Doctrine\ORM\Mapping\QuoteStrategy; | ||
| 19 | use Doctrine\ORM\Mapping\TypedFieldMapper; | ||
| 20 | use Doctrine\ORM\Proxy\ProxyFactory; | ||
| 21 | use Doctrine\ORM\Query\AST\Functions\FunctionNode; | ||
| 22 | use Doctrine\ORM\Query\Filter\SQLFilter; | ||
| 23 | use Doctrine\ORM\Repository\DefaultRepositoryFactory; | ||
| 24 | use Doctrine\ORM\Repository\RepositoryFactory; | ||
| 25 | use Doctrine\Persistence\Mapping\Driver\MappingDriver; | ||
| 26 | use LogicException; | ||
| 27 | use Psr\Cache\CacheItemPoolInterface; | ||
| 28 | |||
| 29 | use function class_exists; | ||
| 30 | use function is_a; | ||
| 31 | use function strtolower; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Configuration container for all configuration options of Doctrine. | ||
| 35 | * It combines all configuration options from DBAL & ORM. | ||
| 36 | * | ||
| 37 | * Internal note: When adding a new configuration option just write a getter/setter pair. | ||
| 38 | */ | ||
| 39 | class Configuration extends \Doctrine\DBAL\Configuration | ||
| 40 | { | ||
| 41 | /** @var mixed[] */ | ||
| 42 | protected array $attributes = []; | ||
| 43 | |||
| 44 | /** @psalm-var array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> */ | ||
| 45 | private $identityGenerationPreferences = []; | ||
| 46 | |||
| 47 | /** @psalm-param array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> $value */ | ||
| 48 | public function setIdentityGenerationPreferences(array $value): void | ||
| 49 | { | ||
| 50 | $this->identityGenerationPreferences = $value; | ||
| 51 | } | ||
| 52 | |||
| 53 | /** @psalm-return array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> $value */ | ||
| 54 | public function getIdentityGenerationPreferences(): array | ||
| 55 | { | ||
| 56 | return $this->identityGenerationPreferences; | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Sets the directory where Doctrine generates any necessary proxy class files. | ||
| 61 | */ | ||
| 62 | public function setProxyDir(string $dir): void | ||
| 63 | { | ||
| 64 | $this->attributes['proxyDir'] = $dir; | ||
| 65 | } | ||
| 66 | |||
| 67 | /** | ||
| 68 | * Gets the directory where Doctrine generates any necessary proxy class files. | ||
| 69 | */ | ||
| 70 | public function getProxyDir(): string|null | ||
| 71 | { | ||
| 72 | return $this->attributes['proxyDir'] ?? null; | ||
| 73 | } | ||
| 74 | |||
| 75 | /** | ||
| 76 | * Gets the strategy for automatically generating proxy classes. | ||
| 77 | * | ||
| 78 | * @return ProxyFactory::AUTOGENERATE_* | ||
| 79 | */ | ||
| 80 | public function getAutoGenerateProxyClasses(): int | ||
| 81 | { | ||
| 82 | return $this->attributes['autoGenerateProxyClasses'] ?? ProxyFactory::AUTOGENERATE_ALWAYS; | ||
| 83 | } | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Sets the strategy for automatically generating proxy classes. | ||
| 87 | * | ||
| 88 | * @param bool|ProxyFactory::AUTOGENERATE_* $autoGenerate True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER. | ||
| 89 | */ | ||
| 90 | public function setAutoGenerateProxyClasses(bool|int $autoGenerate): void | ||
| 91 | { | ||
| 92 | $this->attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; | ||
| 93 | } | ||
| 94 | |||
| 95 | /** | ||
| 96 | * Gets the namespace where proxy classes reside. | ||
| 97 | */ | ||
| 98 | public function getProxyNamespace(): string|null | ||
| 99 | { | ||
| 100 | return $this->attributes['proxyNamespace'] ?? null; | ||
| 101 | } | ||
| 102 | |||
| 103 | /** | ||
| 104 | * Sets the namespace where proxy classes reside. | ||
| 105 | */ | ||
| 106 | public function setProxyNamespace(string $ns): void | ||
| 107 | { | ||
| 108 | $this->attributes['proxyNamespace'] = $ns; | ||
| 109 | } | ||
| 110 | |||
| 111 | /** | ||
| 112 | * Sets the cache driver implementation that is used for metadata caching. | ||
| 113 | * | ||
| 114 | * @todo Force parameter to be a Closure to ensure lazy evaluation | ||
| 115 | * (as soon as a metadata cache is in effect, the driver never needs to initialize). | ||
| 116 | */ | ||
| 117 | public function setMetadataDriverImpl(MappingDriver $driverImpl): void | ||
| 118 | { | ||
| 119 | $this->attributes['metadataDriverImpl'] = $driverImpl; | ||
| 120 | } | ||
| 121 | |||
| 122 | /** | ||
| 123 | * Sets the entity alias map. | ||
| 124 | * | ||
| 125 | * @psalm-param array<string, string> $entityNamespaces | ||
| 126 | */ | ||
| 127 | public function setEntityNamespaces(array $entityNamespaces): void | ||
| 128 | { | ||
| 129 | $this->attributes['entityNamespaces'] = $entityNamespaces; | ||
| 130 | } | ||
| 131 | |||
| 132 | /** | ||
| 133 | * Retrieves the list of registered entity namespace aliases. | ||
| 134 | * | ||
| 135 | * @psalm-return array<string, string> | ||
| 136 | */ | ||
| 137 | public function getEntityNamespaces(): array | ||
| 138 | { | ||
| 139 | return $this->attributes['entityNamespaces']; | ||
| 140 | } | ||
| 141 | |||
| 142 | /** | ||
| 143 | * Gets the cache driver implementation that is used for the mapping metadata. | ||
| 144 | */ | ||
| 145 | public function getMetadataDriverImpl(): MappingDriver|null | ||
| 146 | { | ||
| 147 | return $this->attributes['metadataDriverImpl'] ?? null; | ||
| 148 | } | ||
| 149 | |||
| 150 | /** | ||
| 151 | * Gets the cache driver implementation that is used for the query cache (SQL cache). | ||
| 152 | */ | ||
| 153 | public function getQueryCache(): CacheItemPoolInterface|null | ||
| 154 | { | ||
| 155 | return $this->attributes['queryCache'] ?? null; | ||
| 156 | } | ||
| 157 | |||
| 158 | /** | ||
| 159 | * Sets the cache driver implementation that is used for the query cache (SQL cache). | ||
| 160 | */ | ||
| 161 | public function setQueryCache(CacheItemPoolInterface $cache): void | ||
| 162 | { | ||
| 163 | $this->attributes['queryCache'] = $cache; | ||
| 164 | } | ||
| 165 | |||
| 166 | public function getHydrationCache(): CacheItemPoolInterface|null | ||
| 167 | { | ||
| 168 | return $this->attributes['hydrationCache'] ?? null; | ||
| 169 | } | ||
| 170 | |||
| 171 | public function setHydrationCache(CacheItemPoolInterface $cache): void | ||
| 172 | { | ||
| 173 | $this->attributes['hydrationCache'] = $cache; | ||
| 174 | } | ||
| 175 | |||
| 176 | public function getMetadataCache(): CacheItemPoolInterface|null | ||
| 177 | { | ||
| 178 | return $this->attributes['metadataCache'] ?? null; | ||
| 179 | } | ||
| 180 | |||
| 181 | public function setMetadataCache(CacheItemPoolInterface $cache): void | ||
| 182 | { | ||
| 183 | $this->attributes['metadataCache'] = $cache; | ||
| 184 | } | ||
| 185 | |||
| 186 | /** | ||
| 187 | * Registers a custom DQL function that produces a string value. | ||
| 188 | * Such a function can then be used in any DQL statement in any place where string | ||
| 189 | * functions are allowed. | ||
| 190 | * | ||
| 191 | * DQL function names are case-insensitive. | ||
| 192 | * | ||
| 193 | * @param class-string|callable $className Class name or a callable that returns the function. | ||
| 194 | * @psalm-param class-string<FunctionNode>|callable(string):FunctionNode $className | ||
| 195 | */ | ||
| 196 | public function addCustomStringFunction(string $name, string|callable $className): void | ||
| 197 | { | ||
| 198 | $this->attributes['customStringFunctions'][strtolower($name)] = $className; | ||
| 199 | } | ||
| 200 | |||
| 201 | /** | ||
| 202 | * Gets the implementation class name of a registered custom string DQL function. | ||
| 203 | * | ||
| 204 | * @psalm-return class-string<FunctionNode>|callable(string):FunctionNode|null | ||
| 205 | */ | ||
| 206 | public function getCustomStringFunction(string $name): string|callable|null | ||
| 207 | { | ||
| 208 | $name = strtolower($name); | ||
| 209 | |||
| 210 | return $this->attributes['customStringFunctions'][$name] ?? null; | ||
| 211 | } | ||
| 212 | |||
| 213 | /** | ||
| 214 | * Sets a map of custom DQL string functions. | ||
| 215 | * | ||
| 216 | * Keys must be function names and values the FQCN of the implementing class. | ||
| 217 | * The function names will be case-insensitive in DQL. | ||
| 218 | * | ||
| 219 | * Any previously added string functions are discarded. | ||
| 220 | * | ||
| 221 | * @psalm-param array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions The map of custom | ||
| 222 | * DQL string functions. | ||
| 223 | */ | ||
| 224 | public function setCustomStringFunctions(array $functions): void | ||
| 225 | { | ||
| 226 | foreach ($functions as $name => $className) { | ||
| 227 | $this->addCustomStringFunction($name, $className); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | /** | ||
| 232 | * Registers a custom DQL function that produces a numeric value. | ||
| 233 | * Such a function can then be used in any DQL statement in any place where numeric | ||
| 234 | * functions are allowed. | ||
| 235 | * | ||
| 236 | * DQL function names are case-insensitive. | ||
| 237 | * | ||
| 238 | * @param class-string|callable $className Class name or a callable that returns the function. | ||
| 239 | * @psalm-param class-string<FunctionNode>|callable(string):FunctionNode $className | ||
| 240 | */ | ||
| 241 | public function addCustomNumericFunction(string $name, string|callable $className): void | ||
| 242 | { | ||
| 243 | $this->attributes['customNumericFunctions'][strtolower($name)] = $className; | ||
| 244 | } | ||
| 245 | |||
| 246 | /** | ||
| 247 | * Gets the implementation class name of a registered custom numeric DQL function. | ||
| 248 | * | ||
| 249 | * @psalm-return ?class-string<FunctionNode>|callable(string):FunctionNode | ||
| 250 | */ | ||
| 251 | public function getCustomNumericFunction(string $name): string|callable|null | ||
| 252 | { | ||
| 253 | $name = strtolower($name); | ||
| 254 | |||
| 255 | return $this->attributes['customNumericFunctions'][$name] ?? null; | ||
| 256 | } | ||
| 257 | |||
| 258 | /** | ||
| 259 | * Sets a map of custom DQL numeric functions. | ||
| 260 | * | ||
| 261 | * Keys must be function names and values the FQCN of the implementing class. | ||
| 262 | * The function names will be case-insensitive in DQL. | ||
| 263 | * | ||
| 264 | * Any previously added numeric functions are discarded. | ||
| 265 | * | ||
| 266 | * @psalm-param array<string, class-string> $functions The map of custom | ||
| 267 | * DQL numeric functions. | ||
| 268 | */ | ||
| 269 | public function setCustomNumericFunctions(array $functions): void | ||
| 270 | { | ||
| 271 | foreach ($functions as $name => $className) { | ||
| 272 | $this->addCustomNumericFunction($name, $className); | ||
| 273 | } | ||
| 274 | } | ||
| 275 | |||
| 276 | /** | ||
| 277 | * Registers a custom DQL function that produces a date/time value. | ||
| 278 | * Such a function can then be used in any DQL statement in any place where date/time | ||
| 279 | * functions are allowed. | ||
| 280 | * | ||
| 281 | * DQL function names are case-insensitive. | ||
| 282 | * | ||
| 283 | * @param string|callable $className Class name or a callable that returns the function. | ||
| 284 | * @psalm-param class-string<FunctionNode>|callable(string):FunctionNode $className | ||
| 285 | */ | ||
| 286 | public function addCustomDatetimeFunction(string $name, string|callable $className): void | ||
| 287 | { | ||
| 288 | $this->attributes['customDatetimeFunctions'][strtolower($name)] = $className; | ||
| 289 | } | ||
| 290 | |||
| 291 | /** | ||
| 292 | * Gets the implementation class name of a registered custom date/time DQL function. | ||
| 293 | * | ||
| 294 | * @psalm-return class-string|callable|null | ||
| 295 | */ | ||
| 296 | public function getCustomDatetimeFunction(string $name): string|callable|null | ||
| 297 | { | ||
| 298 | $name = strtolower($name); | ||
| 299 | |||
| 300 | return $this->attributes['customDatetimeFunctions'][$name] ?? null; | ||
| 301 | } | ||
| 302 | |||
| 303 | /** | ||
| 304 | * Sets a map of custom DQL date/time functions. | ||
| 305 | * | ||
| 306 | * Keys must be function names and values the FQCN of the implementing class. | ||
| 307 | * The function names will be case-insensitive in DQL. | ||
| 308 | * | ||
| 309 | * Any previously added date/time functions are discarded. | ||
| 310 | * | ||
| 311 | * @param array $functions The map of custom DQL date/time functions. | ||
| 312 | * @psalm-param array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions | ||
| 313 | */ | ||
| 314 | public function setCustomDatetimeFunctions(array $functions): void | ||
| 315 | { | ||
| 316 | foreach ($functions as $name => $className) { | ||
| 317 | $this->addCustomDatetimeFunction($name, $className); | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | /** | ||
| 322 | * Sets a TypedFieldMapper for php typed fields to DBAL types auto-completion. | ||
| 323 | */ | ||
| 324 | public function setTypedFieldMapper(TypedFieldMapper|null $typedFieldMapper): void | ||
| 325 | { | ||
| 326 | $this->attributes['typedFieldMapper'] = $typedFieldMapper; | ||
| 327 | } | ||
| 328 | |||
| 329 | /** | ||
| 330 | * Gets a TypedFieldMapper for php typed fields to DBAL types auto-completion. | ||
| 331 | */ | ||
| 332 | public function getTypedFieldMapper(): TypedFieldMapper|null | ||
| 333 | { | ||
| 334 | return $this->attributes['typedFieldMapper'] ?? null; | ||
| 335 | } | ||
| 336 | |||
| 337 | /** | ||
| 338 | * Sets the custom hydrator modes in one pass. | ||
| 339 | * | ||
| 340 | * @param array<string, class-string<AbstractHydrator>> $modes An array of ($modeName => $hydrator). | ||
| 341 | */ | ||
| 342 | public function setCustomHydrationModes(array $modes): void | ||
| 343 | { | ||
| 344 | $this->attributes['customHydrationModes'] = []; | ||
| 345 | |||
| 346 | foreach ($modes as $modeName => $hydrator) { | ||
| 347 | $this->addCustomHydrationMode($modeName, $hydrator); | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 351 | /** | ||
| 352 | * Gets the hydrator class for the given hydration mode name. | ||
| 353 | * | ||
| 354 | * @psalm-return class-string<AbstractHydrator>|null | ||
| 355 | */ | ||
| 356 | public function getCustomHydrationMode(string $modeName): string|null | ||
| 357 | { | ||
| 358 | return $this->attributes['customHydrationModes'][$modeName] ?? null; | ||
| 359 | } | ||
| 360 | |||
| 361 | /** | ||
| 362 | * Adds a custom hydration mode. | ||
| 363 | * | ||
| 364 | * @psalm-param class-string<AbstractHydrator> $hydrator | ||
| 365 | */ | ||
| 366 | public function addCustomHydrationMode(string $modeName, string $hydrator): void | ||
| 367 | { | ||
| 368 | $this->attributes['customHydrationModes'][$modeName] = $hydrator; | ||
| 369 | } | ||
| 370 | |||
| 371 | /** | ||
| 372 | * Sets a class metadata factory. | ||
| 373 | * | ||
| 374 | * @psalm-param class-string $cmfName | ||
| 375 | */ | ||
| 376 | public function setClassMetadataFactoryName(string $cmfName): void | ||
| 377 | { | ||
| 378 | $this->attributes['classMetadataFactoryName'] = $cmfName; | ||
| 379 | } | ||
| 380 | |||
| 381 | /** @psalm-return class-string */ | ||
| 382 | public function getClassMetadataFactoryName(): string | ||
| 383 | { | ||
| 384 | if (! isset($this->attributes['classMetadataFactoryName'])) { | ||
| 385 | $this->attributes['classMetadataFactoryName'] = ClassMetadataFactory::class; | ||
| 386 | } | ||
| 387 | |||
| 388 | return $this->attributes['classMetadataFactoryName']; | ||
| 389 | } | ||
| 390 | |||
| 391 | /** | ||
| 392 | * Adds a filter to the list of possible filters. | ||
| 393 | * | ||
| 394 | * @param string $className The class name of the filter. | ||
| 395 | * @psalm-param class-string<SQLFilter> $className | ||
| 396 | */ | ||
| 397 | public function addFilter(string $name, string $className): void | ||
| 398 | { | ||
| 399 | $this->attributes['filters'][$name] = $className; | ||
| 400 | } | ||
| 401 | |||
| 402 | /** | ||
| 403 | * Gets the class name for a given filter name. | ||
| 404 | * | ||
| 405 | * @return string|null The class name of the filter, or null if it is not | ||
| 406 | * defined. | ||
| 407 | * @psalm-return class-string<SQLFilter>|null | ||
| 408 | */ | ||
| 409 | public function getFilterClassName(string $name): string|null | ||
| 410 | { | ||
| 411 | return $this->attributes['filters'][$name] ?? null; | ||
| 412 | } | ||
| 413 | |||
| 414 | /** | ||
| 415 | * Sets default repository class. | ||
| 416 | * | ||
| 417 | * @psalm-param class-string<EntityRepository> $className | ||
| 418 | * | ||
| 419 | * @throws InvalidEntityRepository If $classname is not an ObjectRepository. | ||
| 420 | */ | ||
| 421 | public function setDefaultRepositoryClassName(string $className): void | ||
| 422 | { | ||
| 423 | if (! class_exists($className) || ! is_a($className, EntityRepository::class, true)) { | ||
| 424 | throw InvalidEntityRepository::fromClassName($className); | ||
| 425 | } | ||
| 426 | |||
| 427 | $this->attributes['defaultRepositoryClassName'] = $className; | ||
| 428 | } | ||
| 429 | |||
| 430 | /** | ||
| 431 | * Get default repository class. | ||
| 432 | * | ||
| 433 | * @psalm-return class-string<EntityRepository> | ||
| 434 | */ | ||
| 435 | public function getDefaultRepositoryClassName(): string | ||
| 436 | { | ||
| 437 | return $this->attributes['defaultRepositoryClassName'] ?? EntityRepository::class; | ||
| 438 | } | ||
| 439 | |||
| 440 | /** | ||
| 441 | * Sets naming strategy. | ||
| 442 | */ | ||
| 443 | public function setNamingStrategy(NamingStrategy $namingStrategy): void | ||
| 444 | { | ||
| 445 | $this->attributes['namingStrategy'] = $namingStrategy; | ||
| 446 | } | ||
| 447 | |||
| 448 | /** | ||
| 449 | * Gets naming strategy.. | ||
| 450 | */ | ||
| 451 | public function getNamingStrategy(): NamingStrategy | ||
| 452 | { | ||
| 453 | if (! isset($this->attributes['namingStrategy'])) { | ||
| 454 | $this->attributes['namingStrategy'] = new DefaultNamingStrategy(); | ||
| 455 | } | ||
| 456 | |||
| 457 | return $this->attributes['namingStrategy']; | ||
| 458 | } | ||
| 459 | |||
| 460 | /** | ||
| 461 | * Sets quote strategy. | ||
| 462 | */ | ||
| 463 | public function setQuoteStrategy(QuoteStrategy $quoteStrategy): void | ||
| 464 | { | ||
| 465 | $this->attributes['quoteStrategy'] = $quoteStrategy; | ||
| 466 | } | ||
| 467 | |||
| 468 | /** | ||
| 469 | * Gets quote strategy. | ||
| 470 | */ | ||
| 471 | public function getQuoteStrategy(): QuoteStrategy | ||
| 472 | { | ||
| 473 | if (! isset($this->attributes['quoteStrategy'])) { | ||
| 474 | $this->attributes['quoteStrategy'] = new DefaultQuoteStrategy(); | ||
| 475 | } | ||
| 476 | |||
| 477 | return $this->attributes['quoteStrategy']; | ||
| 478 | } | ||
| 479 | |||
| 480 | /** | ||
| 481 | * Set the entity listener resolver. | ||
| 482 | */ | ||
| 483 | public function setEntityListenerResolver(EntityListenerResolver $resolver): void | ||
| 484 | { | ||
| 485 | $this->attributes['entityListenerResolver'] = $resolver; | ||
| 486 | } | ||
| 487 | |||
| 488 | /** | ||
| 489 | * Get the entity listener resolver. | ||
| 490 | */ | ||
| 491 | public function getEntityListenerResolver(): EntityListenerResolver | ||
| 492 | { | ||
| 493 | if (! isset($this->attributes['entityListenerResolver'])) { | ||
| 494 | $this->attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); | ||
| 495 | } | ||
| 496 | |||
| 497 | return $this->attributes['entityListenerResolver']; | ||
| 498 | } | ||
| 499 | |||
| 500 | /** | ||
| 501 | * Set the entity repository factory. | ||
| 502 | */ | ||
| 503 | public function setRepositoryFactory(RepositoryFactory $repositoryFactory): void | ||
| 504 | { | ||
| 505 | $this->attributes['repositoryFactory'] = $repositoryFactory; | ||
| 506 | } | ||
| 507 | |||
| 508 | /** | ||
| 509 | * Get the entity repository factory. | ||
| 510 | */ | ||
| 511 | public function getRepositoryFactory(): RepositoryFactory | ||
| 512 | { | ||
| 513 | return $this->attributes['repositoryFactory'] ?? new DefaultRepositoryFactory(); | ||
| 514 | } | ||
| 515 | |||
| 516 | public function isSecondLevelCacheEnabled(): bool | ||
| 517 | { | ||
| 518 | return $this->attributes['isSecondLevelCacheEnabled'] ?? false; | ||
| 519 | } | ||
| 520 | |||
| 521 | public function setSecondLevelCacheEnabled(bool $flag = true): void | ||
| 522 | { | ||
| 523 | $this->attributes['isSecondLevelCacheEnabled'] = $flag; | ||
| 524 | } | ||
| 525 | |||
| 526 | public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig): void | ||
| 527 | { | ||
| 528 | $this->attributes['secondLevelCacheConfiguration'] = $cacheConfig; | ||
| 529 | } | ||
| 530 | |||
| 531 | public function getSecondLevelCacheConfiguration(): CacheConfiguration|null | ||
| 532 | { | ||
| 533 | if (! isset($this->attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { | ||
| 534 | $this->attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); | ||
| 535 | } | ||
| 536 | |||
| 537 | return $this->attributes['secondLevelCacheConfiguration'] ?? null; | ||
| 538 | } | ||
| 539 | |||
| 540 | /** | ||
| 541 | * Returns query hints, which will be applied to every query in application | ||
| 542 | * | ||
| 543 | * @psalm-return array<string, mixed> | ||
| 544 | */ | ||
| 545 | public function getDefaultQueryHints(): array | ||
| 546 | { | ||
| 547 | return $this->attributes['defaultQueryHints'] ?? []; | ||
| 548 | } | ||
| 549 | |||
| 550 | /** | ||
| 551 | * Sets array of query hints, which will be applied to every query in application | ||
| 552 | * | ||
| 553 | * @psalm-param array<string, mixed> $defaultQueryHints | ||
| 554 | */ | ||
| 555 | public function setDefaultQueryHints(array $defaultQueryHints): void | ||
| 556 | { | ||
| 557 | $this->attributes['defaultQueryHints'] = $defaultQueryHints; | ||
| 558 | } | ||
| 559 | |||
| 560 | /** | ||
| 561 | * Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned. | ||
| 562 | * | ||
| 563 | * @return mixed The value of the hint or FALSE, if the hint name is not recognized. | ||
| 564 | */ | ||
| 565 | public function getDefaultQueryHint(string $name): mixed | ||
| 566 | { | ||
| 567 | return $this->attributes['defaultQueryHints'][$name] ?? false; | ||
| 568 | } | ||
| 569 | |||
| 570 | /** | ||
| 571 | * Sets a default query hint. If the hint name is not recognized, it is silently ignored. | ||
| 572 | */ | ||
| 573 | public function setDefaultQueryHint(string $name, mixed $value): void | ||
| 574 | { | ||
| 575 | $this->attributes['defaultQueryHints'][$name] = $value; | ||
| 576 | } | ||
| 577 | |||
| 578 | /** | ||
| 579 | * Gets a list of entity class names to be ignored by the SchemaTool | ||
| 580 | * | ||
| 581 | * @return list<class-string> | ||
| 582 | */ | ||
| 583 | public function getSchemaIgnoreClasses(): array | ||
| 584 | { | ||
| 585 | return $this->attributes['schemaIgnoreClasses'] ?? []; | ||
| 586 | } | ||
| 587 | |||
| 588 | /** | ||
| 589 | * Sets a list of entity class names to be ignored by the SchemaTool | ||
| 590 | * | ||
| 591 | * @param list<class-string> $schemaIgnoreClasses List of entity class names | ||
| 592 | */ | ||
| 593 | public function setSchemaIgnoreClasses(array $schemaIgnoreClasses): void | ||
| 594 | { | ||
| 595 | $this->attributes['schemaIgnoreClasses'] = $schemaIgnoreClasses; | ||
| 596 | } | ||
| 597 | |||
| 598 | /** | ||
| 599 | * To be deprecated in 3.1.0 | ||
| 600 | * | ||
| 601 | * @return true | ||
| 602 | */ | ||
| 603 | public function isLazyGhostObjectEnabled(): bool | ||
| 604 | { | ||
| 605 | return true; | ||
| 606 | } | ||
| 607 | |||
| 608 | /** To be deprecated in 3.1.0 */ | ||
| 609 | public function setLazyGhostObjectEnabled(bool $flag): void | ||
| 610 | { | ||
| 611 | if (! $flag) { | ||
| 612 | throw new LogicException(<<<'EXCEPTION' | ||
| 613 | The lazy ghost object feature cannot be disabled anymore. | ||
| 614 | Please remove the call to setLazyGhostObjectEnabled(false). | ||
| 615 | EXCEPTION); | ||
| 616 | } | ||
| 617 | } | ||
| 618 | |||
| 619 | /** To be deprecated in 3.1.0 */ | ||
| 620 | public function setRejectIdCollisionInIdentityMap(bool $flag): void | ||
| 621 | { | ||
| 622 | if (! $flag) { | ||
| 623 | throw new LogicException(<<<'EXCEPTION' | ||
| 624 | Rejecting ID collisions in the identity map cannot be disabled anymore. | ||
| 625 | Please remove the call to setRejectIdCollisionInIdentityMap(false). | ||
| 626 | EXCEPTION); | ||
| 627 | } | ||
| 628 | } | ||
| 629 | |||
| 630 | /** | ||
| 631 | * To be deprecated in 3.1.0 | ||
| 632 | * | ||
| 633 | * @return true | ||
| 634 | */ | ||
| 635 | public function isRejectIdCollisionInIdentityMapEnabled(): bool | ||
| 636 | { | ||
| 637 | return true; | ||
| 638 | } | ||
| 639 | |||
| 640 | public function setEagerFetchBatchSize(int $batchSize = 100): void | ||
| 641 | { | ||
| 642 | $this->attributes['fetchModeSubselectBatchSize'] = $batchSize; | ||
| 643 | } | ||
| 644 | |||
| 645 | public function getEagerFetchBatchSize(): int | ||
| 646 | { | ||
| 647 | return $this->attributes['fetchModeSubselectBatchSize'] ?? 100; | ||
| 648 | } | ||
| 649 | } | ||
