Skip to content

Commit

Permalink
Fix an edge case where annotations where not loaded if audited entiti…
Browse files Browse the repository at this point in the history
…es were set in configuration. (#50)
  • Loading branch information
DamienHarper authored Sep 27, 2021
1 parent 6b4be4a commit c652ff0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Provider/Doctrine/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class Configuration implements ConfigurationInterface
*/
private $storageMapper;

/**
* @var array
*/
private $annotationLoaded = [];

public function __construct(array $options)
{
$resolver = new OptionsResolver();
Expand Down Expand Up @@ -179,11 +184,15 @@ public function getIgnoredColumns(): array
*/
public function getEntities(): array
{
if (null === $this->entities && null !== $this->provider) {
if (null !== $this->provider) {
/** @var AuditingService[] $auditingServices */
$auditingServices = $this->provider->getAuditingServices();
foreach ($auditingServices as $auditingService) {
$this->provider->loadAnnotations($auditingService->getEntityManager(), []);
// do not load annotations if they're already loaded
if (!isset($this->annotationLoaded[$auditingService->getName()]) || !$this->annotationLoaded[$auditingService->getName()]) {
$this->provider->loadAnnotations($auditingService->getEntityManager(), null === $this->entities ? [] : $this->entities);
$this->annotationLoaded[$auditingService->getName()] = true;
}
}
}

Expand Down

0 comments on commit c652ff0

Please sign in to comment.