/**
  * Upload a new image, and return its metadata.
  *
  * Depending on the $metadata argument it will return asset metadata for the AssetEditor
  * or image metadata for the ImageEditor
  *
  * @param Asset $asset
  * @param string $metadata Type of metadata to return ("Asset" or "Image")
  * @return string
  */
 public function uploadAssetAction(Asset $asset, $metadata)
 {
     $this->response->setHeader('Content-Type', 'application/json');
     /** @var Site $currentSite */
     $currentSite = $this->siteRepository->findOneByNodeName($this->request->getInternalArgument('__siteNodeName'));
     if ($currentSite !== null && $currentSite->getAssetCollection() !== null) {
         $currentSite->getAssetCollection()->addAsset($asset);
         $this->assetCollectionRepository->update($currentSite->getAssetCollection());
     }
     switch ($metadata) {
         case 'Asset':
             $result = $this->getAssetProperties($asset);
             if ($this->persistenceManager->isNewObject($asset)) {
                 $this->assetRepository->add($asset);
             }
             break;
         case 'Image':
             $result = $this->getImageInterfacePreviewData($asset);
             if ($this->persistenceManager->isNewObject($asset)) {
                 $this->imageRepository->add($asset);
             }
             break;
         default:
             $this->response->setStatus(400);
             $result = array('error' => 'Invalid "metadata" type: ' . $metadata);
     }
     return json_encode($result);
 }
 /**
  * @param AssetCollection $assetCollection
  * @return void
  */
 public function updateAssetCollectionAction(AssetCollection $assetCollection)
 {
     $this->assetCollectionRepository->update($assetCollection);
     $this->addFlashMessage('collectionHasBeenUpdated', '', Message::SEVERITY_OK, [htmlspecialchars($assetCollection->getTitle())]);
     $this->redirect('index');
 }