src/Logging/DeletionContextLogger.php line 20

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