src/AppRemix/Logging/Objects/ReportLog.php line 17

Open in your IDE?
  1. <?php
  2. //----------------------------------------------------------------------
  3. // src/AppRemix/Logging/ReportLog.php
  4. //----------------------------------------------------------------------
  5. namespace App\AppRemix\Logging\Objects;
  6. use Doctrine\Persistence\ManagerRegistry;
  7. use App\AppRemix\Entity\Report;
  8. use App\AppRemix\Logging\Tools;
  9. use App\Services\LogTools;
  10. class ReportLog
  11. {
  12.     private array $pendingLogArgs = [];
  13.     public function __construct(ManagerRegistry $doctrine, LogTools $logTools, Tools $tools)
  14.     {
  15.         $this->em = $doctrine->getManager();
  16.         $this->logTools = $logTools;
  17.         $this->tools = $tools;
  18.     }
  19.     public function logCreation(Report $report)
  20.     {
  21.         $pendingLogArgs = [];
  22.         //----------------------------------------------------------------------
  23.         // Fetch eventual info stored in the object
  24.         $loggingData = $this->logTools->handleLoggingData($report);
  25.         $info = $loggingData['info'];        
  26.         $ignore = $loggingData['ignore'];
  27.         if ($ignore) return $pendingLogArgs;
  28.         //----------------------------------------------------------------------
  29.         // Init base log args
  30.         // This does not contain action
  31.         $args = $this->initArgs($report, $loggingData);
  32.         //----------------------------------------------------------------------
  33.         $action = "report_add";
  34.         $args["action"] = $action;
  35.         $pendingLogArgs[] = $args;
  36.         return $pendingLogArgs;
  37.     }
  38.     public function logChanges(Report $report, $changes)
  39.     {
  40.         $pendingLogArgs = [];
  41.         return $pendingLogArgs;
  42.     }
  43.     public function logRemoval(Report $report)
  44.     {
  45.         $pendingLogArgs = [];
  46.         return $pendingLogArgs;
  47.     }
  48.     private function initArgs(Report $report, $loggingData)
  49.     {
  50.         $args = array(
  51.             "object_id"                    =>    $report->getId(),            
  52.             "object_entity"                =>    "Report",
  53.             "object_display"            =>    $report->display(),
  54.             
  55.             "society"                    =>    $report->getSociety(),
  56.             "info"                        =>    $loggingData['info'],            
  57.         );
  58.         return $args;
  59.     }
  60. }