addTag() публичный Метод

Add a single tag to this asset
public addTag ( Tag $tag ) : boolean
$tag Tag The tag to add
Результат boolean TRUE if the tag added was new, FALSE if it already existed
 /**
  * @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();
     }
 }
 /**
  * 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);
 }