src/AppRemix/Logging/DeletionContextLogger.php line 18

Open in your IDE?
  1. <?php
  2. //----------------------------------------------------------------------
  3. // src/AppRemix/Logging/DeletionContextLogger.php
  4. // Doctrine’s remove process may clean out relationships depending on fetch strategy,
  5. // cascade settings, and state of the UnitOfWork.
  6. //----------------------------------------------------------------------
  7. namespace App\AppRemix\Logging;
  8. use Doctrine\Persistence\ManagerRegistry;
  9. use App\Services\LogTools;
  10. class DeletionContextLogger
  11. {
  12.     public function __construct(ManagerRegistry $doctrine, LogTools $logTools)
  13.     {
  14.         $this->em = $doctrine->getManager();
  15.         $this->logTools = $logTools;
  16.     }
  17.     private array $context = [];
  18.     public function storeContext(object $entity, array $data): void
  19.     {
  20.         $this->context[spl_object_hash($entity)] = $data;
  21.     }
  22.     public function getContext(object $entity): ?array
  23.     {
  24.         return $this->context[spl_object_hash($entity)] ?? null;
  25.     }
  26.     public function clear(): void
  27.     {
  28.         $this->context = [];
  29.     }
  30. }