Skip to content

Commit

Permalink
Fixed invokable storage mapper (see #146) (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienHarper authored Dec 15, 2022
1 parent 11d5d2f commit 1de4929
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ private function value(EntityManagerInterface $entityManager, Type $type, $value
if (null === $value) {
return null;
}
if (interface_exists(UnitEnum::class) && $value instanceof UnitEnum && property_exists($value, 'value')) {

if (interface_exists(UnitEnum::class) && $value instanceof UnitEnum && property_exists($value, 'value')) { /** @phpstan-ignore-line */
$value = $value->value;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Provider/Doctrine/DoctrineProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public function getStorageServiceForEntity(string $entity): StorageServiceInterf
return array_values($this->getStorageServices())[0];
}

if (\is_string($storageMapper) && class_exists($storageMapper)) {
$storageMapper = new $storageMapper();
}

\assert(\is_callable($storageMapper)); // helps PHPStan

return $storageMapper($entity, $this->getStorageServices());
Expand Down

0 comments on commit 1de4929

Please sign in to comment.