예제 #1
0
 public function updateAction($json)
 {
     $albumDto = $this->parseJson($json);
     $userAlbum = $this->userAlbumRepository->find($albumDto->id);
     $userBand = $userAlbum->getBand();
     $this->albumHelper->populateUserAlbumWithDto($userAlbum, $albumDto);
     $album = $this->albumRepository->findOneByBandAndTitle($userBand->getGlobalBand(), $userAlbum->getTitle());
     if ($album == null) {
         $album = $this->albumHelper->convertDtoToAlbum($albumDto);
         $this->albumRepository->persist($album);
     }
     $userAlbum->setAlbum($album);
     $this->userAlbumRepository->flush();
     $resultDto = $this->albumHelper->convertUserAlbumToDto($userAlbum);
     return new JsonViewModel($resultDto, $this->jsonUtils);
 }