Skip to content

Commit

Permalink
Disable proxy's auto refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Ben87 committed Jul 11, 2023
1 parent 3a3b606 commit f9098f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/ExpressionLanguage/Evaluator/FactoryEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ public function __invoke(
return PropertyAccess::createPropertyAccessor()->getValue($value->object(), $accessor);
}

if (\is_array($value)) {
$value = new ArrayCollection(array_map(static fn (Proxy $proxy): object => $proxy->object(), $value));
switch (true) {
case \is_array($value):
$value = new ArrayCollection(array_map(static fn (Proxy $proxy): object => $proxy->object(), $value));
break;

case $value instanceof Proxy:
$value->disableAutoRefresh();
break;
}

return $value;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Adapter/FactoryAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function values(): iterable
{
yield 'a string containing only a factory expression with a factory name and an array of attributes'
. ' should find and return the relevant object proxy' => [
static fn () => UserFactory::find(['firstname' => 'John']),
static fn () => UserFactory::find(['firstname' => 'John'])->disableAutoRefresh(),
'<factory("user", {"firstname": "John"})>',
];
yield 'a string containing only a factory expression'
Expand Down

0 comments on commit f9098f7

Please sign in to comment.