protected function dispatch(KalturaBatchJob $job, KalturaEventNotificationDispatchJobData $data) { $this->updateJob($job, "Dispatch template [{$data->templateId}]", KalturaBatchJobStatus::QUEUED); $eventNotificationPlugin = KalturaEventNotificationClientPlugin::get(self::$kClient); $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->get($data->templateId); $engine = $this->getEngine($job->jobSubType); if (!$engine) { return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::ENGINE_NOT_FOUND, "Engine not found", KalturaBatchJobStatus::FAILED); } $this->impersonate($job->partnerId); $engine->dispatch($eventNotificationTemplate, $data); $this->unimpersonate(); return $this->closeJob($job, null, null, "Dispatched", KalturaBatchJobStatus::FINISHED, $data); }
/** * @param KalturaBaseEntry $object */ function processObject($object) { /** @var KalturaDispatchEventNotificationObjectTask $objectTask */ $objectTask = $this->getObjectTask(); if (is_null($objectTask)) { return; } $client = $this->getClient(); $templateId = $objectTask->eventNotificationTemplateId; $eventNotificationPlugin = KalturaEventNotificationClientPlugin::get($client); $scope = new KalturaEventNotificationScope(); $scope->objectId = $object->id; $scope->scopeObjectType = KalturaEventNotificationEventObjectType::ENTRY; $this->impersonate($object->partnerId); try { $eventNotificationPlugin->eventNotificationTemplate->dispatch($templateId, $scope); $this->unimpersonate(); } catch (Exception $ex) { $this->unimpersonate(); throw $ex; } }