/** * @param Asset $asset * @param MetaDataCollection $metaDataCollection */ protected function buildAssetMetaData(Asset $asset, MetaDataCollection $metaDataCollection) { $tags = []; /** @var \TYPO3\Media\Domain\Model\Tag $tagObject */ foreach ($asset->getTags() as $tagObject) { $tags[] = $tagObject->getLabel(); } $collections = []; /** @var \TYPO3\Media\Domain\Model\AssetCollection $collectionObject */ foreach ($asset->getAssetCollections() as $collectionObject) { $collections[] = $collectionObject->getTitle(); } $assetDto = new Dto\Asset(['Caption' => $asset->getCaption(), 'Identifier' => $asset->getIdentifier(), 'Title' => $asset->getTitle(), 'FileName' => $asset->getResource()->getFilename(), 'Collections' => $collections, 'Tags' => $tags, 'AssetObject' => $asset]); $metaDataCollection->set('asset', $assetDto); }
/** * @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); }