/**
* {@inheritdoc}
*/
public function move($id, $locale, $destinationId = null)
{
try {
$collectionEntity = $this->collectionRepository->findCollectionById($id);
if ($collectionEntity === null) {
throw new CollectionNotFoundException($id);
}
$destinationEntity = null;
if ($destinationId !== null) {
$destinationEntity = $this->collectionRepository->findCollectionById($destinationId);
}
$collectionEntity->setParent($destinationEntity);
$this->em->flush();
return $this->getApiEntity($collectionEntity, $locale);
} catch (DBALException $ex) {
throw new CollectionNotFoundException($destinationId);
}
}