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

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. use App\Centralstage\CoreBundle\Service\SecretsService;
  11. class DeviceSummarySubscriber implements EventSubscriberInterface
  12. {
  13.     public function onDeviceSummary(Devicesummary $Devicesummary): void
  14.     {   
  15.         try{
  16.             //DATA
  17.             $EventData       $Devicesummary->getData();
  18.             $rawData         base64_encode($EventData["rawData"]);
  19.             $orgID           $EventData["orgID"];
  20.             // $phpExecutable  = $_ENV['PHP_EXECUTABLE_PATH']; 
  21.             $phpExecutable  SecretsService::get('PHP_EXECUTABLE_PATH''php'); 
  22.             $projectRoot    PreGenerateDataService::ProjectPhpBinPath();
  23.             if(!empty($rawData) && !empty($orgID)){
  24.                 $command        = [$phpExecutable,"$projectRoot/bin/console",'app:summaryV2',$rawData,$orgID];
  25.                 $process        = new Process($command);
  26.                 $process->start();
  27.                 while ($process->isRunning()) {
  28.                 }
  29.             }else{
  30.                 // LogService::log("error message missing arguments orgID:$orgID rawData:$rawData ", "pushMissingArguments");
  31.             }
  32.             
  33.             unset($EventData); //free memory
  34.         }catch (\Exception $exception) { $error $exception->getMessage(); }
  35.     }
  36.     public static function getSubscribedEvents(): array
  37.     {
  38.         return [
  39.             'device.summary.process' => 'onDeviceSummary'
  40.         ];
  41.     }
  42. }