Skip to content

Commit

Permalink
Keep a single ProxyManagerConfiguration instance
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jan 21, 2025
1 parent 564f32d commit 1ce91ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ class Configuration

private ?CacheItemPoolInterface $metadataCache = null;

/** @deprecated */
private ProxyManagerConfiguration $proxyManagerConfiguration;

private bool $useTransactionalFlush = false;

private bool $useLazyGhostObject = true;


/**
* Adds a namespace under a certain alias.
*/
Expand Down Expand Up @@ -256,6 +260,7 @@ public function setMetadataCache(CacheItemPoolInterface $cache): void
public function setProxyDir(string $dir): void
{
$this->attributes['proxyDir'] = $dir;
unset($this->proxyManagerConfiguration);
}

/**
Expand Down Expand Up @@ -288,6 +293,7 @@ public function getAutoGenerateProxyClasses(): int
public function setAutoGenerateProxyClasses(int $mode): void
{
$this->attributes['autoGenerateProxyClasses'] = $mode;
unset($this->proxyManagerConfiguration);
}

public function getProxyNamespace(): ?string
Expand All @@ -298,6 +304,7 @@ public function getProxyNamespace(): ?string
public function setProxyNamespace(string $ns): void
{
$this->attributes['proxyNamespace'] = $ns;
unset($this->proxyManagerConfiguration);
}

public function setHydratorDir(string $dir): void
Expand Down Expand Up @@ -586,6 +593,10 @@ public function buildGhostObjectFactory(): LazyLoadingGhostFactory
/** @deprecated */
public function getProxyManagerConfiguration(): ProxyManagerConfiguration
{
if (isset($this->proxyManagerConfiguration)) {
return $this->proxyManagerConfiguration;
}

$proxyManagerConfiguration = new ProxyManagerConfiguration();
$proxyManagerConfiguration->setProxiesTargetDir($this->getProxyDir());
$proxyManagerConfiguration->setProxiesNamespace($this->getProxyNamespace());
Expand All @@ -605,7 +616,7 @@ public function getProxyManagerConfiguration(): ProxyManagerConfiguration
throw new InvalidArgumentException('Invalid proxy generation strategy given - only AUTOGENERATE_FILE_NOT_EXISTS and AUTOGENERATE_EVAL are supported.');
}

return $proxyManagerConfiguration;
return $this->proxyManagerConfiguration = $proxyManagerConfiguration;
}

public function setUseTransactionalFlush(bool $useTransactionalFlush): void
Expand Down

0 comments on commit 1ce91ac

Please sign in to comment.