Skip to content

Commit

Permalink
Update BaseListener.php
Browse files Browse the repository at this point in the history
  • Loading branch information
thorewi authored Mar 25, 2024
1 parent 74ec2e2 commit 050a6b6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/BaseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class BaseListener implements EventSubscriber
protected EntityManagerDecorator $em;

/** @var callable[] */
protected array $postFlush = [];
private array $postFlush = [];

/** @var callable[] */
protected array $entitiesToCompute = [];
Expand Down Expand Up @@ -170,4 +170,13 @@ protected function recalculateEntities(): void
$this->em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->em->getClassMetadata($_entity::class), $_entity);
}
}
}

final protected function addPostFlushCallback(callable $callback): void
{
if (!isset($this->getSubscribedEvents()['postFlush'])) {
throw new \Exception ('Missing postFlush subsribed event.');
}

$this->postFlush[] = $callback;
}
}

0 comments on commit 050a6b6

Please sign in to comment.