示例#1
0
 /**
  * @param \LineStorm\MediaBundle\Model\Media $media
  * @param array                              $api
  */
 function __construct(\LineStorm\MediaBundle\Model\Media $media, array $api = array())
 {
     $this->alt = $media->getAlt();
     $this->credits = $media->getCredits();
     $this->hash = $media->getHash();
     $this->id = $media->getId();
     $this->name = $media->getName();
     $this->nameOriginal = $media->getNameOriginal();
     $this->src = $media->getSrc();
     $this->title = $media->getTitle();
     $this->path = $media->getPath();
     $this->category = $media->getCategory();
     $this->_api = $api;
 }
 /**
  * @inheritdoc
  */
 public function delete(Media $media)
 {
     $file = $media->getPath();
     if ($media->getSrc() && file_exists($file) && is_file($file)) {
         unlink($file);
     }
     // index the media object
     if ($this->searchProvider) {
         $this->searchProvider->remove($media);
     }
     $this->em->remove($media);
     $this->em->flush();
 }