/** * @return string */ public function execute() { $photo = new Photo(); $photo->setTags($this->photoDTO->getTags()); $photo->setThumbnails($this->photoDTO->getUrls()); return $this->repository->store($photo); }
/** * @param PhotoDocument $photoDocument * @return Photo */ public function buildPhotoEntity(PhotoDocument $photoDocument) { $photo = new Photo(); $photo->setThumbnails($photoDocument->getThumbnails()); $photo->setId($photoDocument->getId()); $photo->setTags($this->buildTagData($photoDocument->getTags())); return $photo; }
/** * @param int $howManyPhotos * @param array $tagNames */ protected function loadFixture($howManyPhotos, array $tagNames) { for ($i = 1; $i <= $howManyPhotos; $i++) { $thumbnails[Photo::THUMBNAIL_SMALL] = uniqid('small'); $thumbnails[Photo::THUMBNAIL_STANDARD] = uniqid('standard'); $photo = new Photo(); $photo->setTags($tagNames); $photo->setThumbnails($thumbnails); $this->repository->store($photo); } }
/** * @param Photo $document * @return Photo */ public function store(Photo $document) { if ($document->getId() === null) { $id = uniqid(); $document->setId($id); } else { $id = $document->getId(); } $this->photos[$id] = $document; return $id; }
/** * @param Photo $photo * @return Photo */ public function store(Photo $photo) { $document = new PhotoDocument(); $tags = []; foreach ($photo->getTags() as $tag) { $tags[] = new TagDocument($tag->getName()); } $document->setTags($tags); $document->setThumbnails($photo->getThumbnails()); $this->getDocumentManager()->persist($document); $this->getDocumentManager()->flush(); $photo->setId((string) $document->getId()); return $photo; }