Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9489e83

Browse files
authored
fix: 🐛 use isser instead of constructor to apply autorefresh setting to Factory (#998)
1 parent e5bda6b commit 9489e83

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/Persistence/PersistentObjectFactory.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,7 @@ abstract class PersistentObjectFactory extends ObjectFactory
5151

5252
private bool $isRootFactory = true;
5353

54-
private bool $autorefreshEnabled = false;
55-
56-
public function __construct()
57-
{
58-
parent::__construct();
59-
60-
$this->autorefreshEnabled = Configuration::autoRefreshWithLazyObjectsIsEnabled();
61-
}
54+
private bool|null $autorefreshEnabled = null;
6255

6356
/**
6457
* @phpstan-param mixed|Parameters $criteriaOrId
@@ -525,7 +518,7 @@ static function(object $object, array $parameters, PersistentObjectFactory $fact
525518
}
526519

527520
if (
528-
$factoryUsed->autorefreshEnabled
521+
$factoryUsed->isAutorefreshEnabled()
529522
&& !$factoryUsed instanceof PersistentProxyObjectFactory
530523
) {
531524
Configuration::instance()->persistedObjectsTracker?->add($object);
@@ -545,6 +538,11 @@ static function(object $object, array $parameters, PersistentObjectFactory $fact
545538
;
546539
}
547540

541+
private function isAutorefreshEnabled(): bool
542+
{
543+
return $this->autorefreshEnabled ??= Configuration::autoRefreshWithLazyObjectsIsEnabled();
544+
}
545+
548546
private function throwIfCannotCreateObject(): void
549547
{
550548
$configuration = Configuration::instance();

0 commit comments

Comments
 (0)