public function getDomainModel(\TubeService\Data\Database\Entity\Status $item) : Status { $id = new ID($item->getID()); $descriptions = null; $description = $item->getDescription(); if ($description) { $descriptions = explode('|', $description); } $line = new Status($id, $item->getCreatedAt(), $item->getUpdatedAt(), $item->getIsDisrupted(), $item->getShortTitle(), $item->getTitle(), $descriptions); return $line; }
public function addNewStatus(Line $line, TFLLine $TFLLine) { // get the original lineEntity out of the database $lineEntity = $this->entityManager->find('TubeService:Line', $line->getId()); // create a new status for this line $status = new StatusDb(); $status->setLine($lineEntity); $description = null; $descriptions = $TFLLine->getStatusDescriptions(); if ($descriptions) { $description = implode('|', $descriptions); } $status->setDescription($description); $status->setIsDisrupted($TFLLine->isDisrupted()); $status->setTitle($TFLLine->getStatusTitle()); $status->setShortTitle($TFLLine->getStatusShortTitle()); $this->entityManager->persist($status); $this->entityManager->flush(); // use the new status ID to update the line $lineEntity->setLatestStatus($status); $this->entityManager->persist($lineEntity); $this->entityManager->flush(); return $status; }