private function insertStopPoint($externalStopPointId, $timetable) { $stopPoint = new StopPoint(); $stopPoint->setExternalId($externalStopPointId); $stopPoint->setTimetable($timetable); $this->getEntityManager()->persist($stopPoint); return $stopPoint; }
private function commit($task) { $lineConfig = false; $timetable = false; foreach ($task->getAmqpAcks() as $ack) { try { if ($ack->getPayload()->generated == true) { $lineConfig = $this->getLineConfig($ack, $lineConfig); $timetable = $this->getTimetable($ack, $lineConfig, $timetable); $stopPoint = $this->getStopPoint($ack, $timetable); if (empty($stopPoint)) { $stopPoint = new StopPoint(); $stopPoint->setTimetable($timetable); $stopPoint->setExternalId($ack->getPayload()->timetableParams->externalStopPointId); } $stopPoint->setPdfHash($ack->getPayload()->generationResult->pdfHash); $pdfGenerationDate = new \DateTime(); $pdfGenerationDate->setTimestamp($ack->getPayload()->generationResult->created); $stopPoint->setPdfGenerationDate($pdfGenerationDate); $this->om->persist($stopPoint); $this->mediaManager->saveStopPointTimetable($timetable, $stopPoint->getExternalId(), $ack->getPayload()->generationResult->filepath); $this->removeTmpMedia($timetable, $stopPoint->getExternalId()); } elseif (isset($ack->getPayload()->error)) { throw new \Exception('Ack error msg: ' . $ack->getPayload()->error); } } catch (\Exception $e) { $task->fail(); echo "ERROR during task Completion, task n°" . $task->getId() . "\n"; echo $e->getMessage() . "\n"; } } $task->complete(); }