src/Centralstage/DeviceBundle/EventSubscriber/DeviceSummarySubscriber.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Centralstage\DeviceBundle\EventSubscriber;
  3. use App\Centralstage\CoreBundle\Service\LogService;
  4. use App\Centralstage\DeviceBundle\Event\DeviceSummaryEvent as Devicesummary;
  5. use App\Centralstage\DeviceBundle\Models\DeviceDataModel;
  6. use App\Centralstage\CoreBundle\Utils\FileHelper;
  7. use App\Centralstage\ProductionMonitoringBundle\Service\PreGenerateDataService;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. use Symfony\Component\Process\Process;
  10. class DeviceSummarySubscriber implements EventSubscriberInterface
  11. {
  12.     public function onDeviceSummary(Devicesummary $Devicesummary): void
  13.     {   
  14.         try{
  15.             //DATA
  16.             $EventData       $Devicesummary->getData();
  17.             $rawData         base64_encode($EventData["rawData"]);
  18.             $orgID           $EventData["orgID"];
  19.             $phpExecutable  $_ENV['PHP_EXECUTABLE_PATH']; 
  20.             $projectRoot    PreGenerateDataService::ProjectPhpBinPath();
  21.             if(!empty($rawData) && !empty($orgID)){
  22.                 $command        = [$phpExecutable,"$projectRoot/bin/console",'app:summaryV2',$rawData,$orgID];
  23.                 $process        = new Process($command);
  24.                 $process->start();
  25.                 while ($process->isRunning()) {
  26.                 }
  27.             }else{
  28.                 // LogService::log("error message missing arguments orgID:$orgID rawData:$rawData ", "pushMissingArguments");
  29.             }
  30.             
  31.             unset($EventData); //free memory
  32.         }catch (\Exception $exception) { $error $exception->getMessage(); }
  33.     }
  34.     public static function getSubscribedEvents(): array
  35.     {
  36.         return [
  37.             'device.summary.process' => 'onDeviceSummary'
  38.         ];
  39.     }
  40. }