It can be used as is to represent any asset for which no better match is available.
Inheritance: implements Neos\Media\Domain\Model\AssetInterface
 /**
  * Constructs the object and sets default values for width and height
  *
  * @param PersistentResource $resource
  */
 public function __construct(PersistentResource $resource)
 {
     parent::__construct($resource);
     $this->width = -1;
     $this->height = -1;
 }
 /**
  * @param Asset $asset
  * @param $tagLabels
  */
 protected function assertAssetHasTags(Asset $asset, $tagLabels)
 {
     $tags = $asset->getTags();
     $tagLabels = array_combine(array_values($tagLabels), array_values($tagLabels));
     $expectedTagLabels = $tagLabels;
     foreach ($tags as $tag) {
         $this->assertArrayHasKey($tag->getLabel(), $expectedTagLabels);
         unset($expectedTagLabels[$tag->getLabel()]);
     }
     $this->assertCount(0, $expectedTagLabels);
 }
 /**
  * Calculates image width and height from the image resource.
  *
  * @throws ImageFileException
  * @return void
  */
 public function refresh()
 {
     $this->calculateDimensionsFromResource($this->resource);
     parent::refresh();
 }
 /**
  * @test
  */
 public function findBySearchTermAndTagsReturnsFilteredResult()
 {
     $tag = new Tag('home');
     $this->tagRepository->add($tag);
     $resource1 = $this->resourceManager->importResource(__DIR__ . '/../../Fixtures/Resources/license.txt');
     $resource2 = $this->resourceManager->importResource(__DIR__ . '/../../Fixtures/Resources/417px-Mihaly_Csikszentmihalyi.jpg');
     $asset1 = new Asset($resource1);
     $asset1->setTitle('asset for homepage');
     $asset2 = new Asset($resource2);
     $asset2->setTitle('just another asset');
     $asset2->addTag($tag);
     $this->assetRepository->add($asset1);
     $this->assetRepository->add($asset2);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->assertCount(2, $this->assetRepository->findBySearchTermOrTags('home', array($tag)));
     $this->assertCount(2, $this->assetRepository->findBySearchTermOrTags('homepage', array($tag)));
     $this->assertCount(1, $this->assetRepository->findBySearchTermOrTags('baz', array($tag)));
     // This is necessary to initialize all resource instances before the tables are deleted
     foreach ($this->assetRepository->findAll() as $asset) {
         $asset->getResource()->getSha1();
     }
 }
 /**
  * Refreshes this image variant: according to the added adjustments, a new image is rendered and stored as this
  * image variant's resource.
  *
  * @return void
  * @see getResource()
  */
 public function refresh()
 {
     // Several refresh() calls might happen during one request. If that is the case, the Resource Manager can't know
     // that the first created resource object doesn't have to be persisted / published anymore. Thus we need to
     // delete the resource manually in order to avoid orphaned resource objects:
     if ($this->resource !== null) {
         $this->resourceManager->deleteResource($this->resource);
     }
     parent::refresh();
     $this->renderResource();
 }
 /**
  * Tags an asset with a tag.
  *
  * No redirection and no response body, no flash message, for use by plupload (or similar).
  *
  * @param Asset $asset
  * @param Tag $tag
  * @return boolean
  */
 public function tagAssetAction(Asset $asset, Tag $tag)
 {
     $success = false;
     if ($asset->addTag($tag)) {
         $this->assetRepository->update($asset);
         $success = true;
     }
     $this->view->assign('value', $success);
 }