/**
  * @param FlowResource $resource
  * @param MetaDataCollection $metaDataCollection
  * @throws \TYPO3\Flow\Resource\Exception
  */
 public function extractMetaData(FlowResource $resource, MetaDataCollection $metaDataCollection)
 {
     $manager = new ImageManager(['driver' => 'gd']);
     $image = $manager->make($resource->createTemporaryLocalCopy());
     $iptcData = $image->iptc();
     if (is_array($iptcData)) {
         $metaDataCollection->set('iptc', $this->buildIptcDto($iptcData));
     }
     $exifData = $image->exif();
     if (is_array($exifData)) {
         $metaDataCollection->set('exif', $this->buildExifDto($exifData));
     }
 }
Ejemplo n.º 2
0
 /**
  * @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 AbstractNodeData $nodeData
  * @param NodeType $nodeType
  * @param MetaDataCollection $metaDataCollection
  * @throws \TYPO3\Eel\Exception
  */
 protected function mapMetaDataToNodeData(AbstractNodeData $nodeData, NodeType $nodeType, MetaDataCollection $metaDataCollection)
 {
     if ($this->defaultContextVariables === NULL) {
         $this->defaultContextVariables = EelUtility::getDefaultContextVariables($this->settings['defaultEelContext']);
     }
     foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) {
         $contextVariables = array_merge($this->defaultContextVariables, $metaDataCollection->toArray());
         if (isset($propertyConfiguration['mapping'])) {
             $nodeData->setProperty($propertyName, EelUtility::evaluateEelExpression($propertyConfiguration['mapping'], $this->eelEvaluator, $contextVariables));
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param Asset $asset
  * @param MetaDataCollection $metaDataCollection
  */
 public function mapMetaData(Asset $asset, MetaDataCollection $metaDataCollection)
 {
     $contextVariables = array_merge($this->defaultContextVariables, $metaDataCollection->toArray());
     if (isset($this->metaDataMappingConfiguration['title'])) {
         $asset->setTitle(substr((string) EelUtility::evaluateEelExpression($this->metaDataMappingConfiguration['title'], $this->eelEvaluator, $contextVariables), 0, 255));
     }
     if (isset($this->metaDataMappingConfiguration['caption'])) {
         $asset->setCaption((string) EelUtility::evaluateEelExpression($this->metaDataMappingConfiguration['caption'], $this->eelEvaluator, $contextVariables));
     }
     if (isset($this->metaDataMappingConfiguration['tags'])) {
         $tagLabels = EelUtility::evaluateEelExpression($this->metaDataMappingConfiguration['tags'], $this->eelEvaluator, $contextVariables);
         $tagLabels = array_unique($tagLabels);
         $tags = new ArrayCollection();
         foreach ($tagLabels as $tagLabel) {
             if (trim($tagLabel) !== '') {
                 $tags->add($this->getOrCreateTag(trim($tagLabel)));
             }
         }
         $asset->setTags($tags);
     }
     if (isset($this->metaDataMappingConfiguration['collections'])) {
         $collectionTitles = EelUtility::evaluateEelExpression($this->metaDataMappingConfiguration['collections'], $this->eelEvaluator, $contextVariables);
         $collectionTitles = array_unique($collectionTitles);
         $collections = new ArrayCollection();
         foreach ($collectionTitles as $collectionTitle) {
             if (trim($collectionTitle) !== '') {
                 $collections->add($this->getOrCreateCollection(trim($collectionTitle)));
             }
         }
         $asset->setAssetCollections($collections);
     }
     if (!$this->persistenceManager->isNewObject($asset)) {
         $this->assetRepository->update($asset);
     }
 }