/** * @param Asset $asset * @param MetaDataCollection $metaDataCollection * @throws NodeTypeNotFoundException * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException * @return void */ public function mapMetaData(Asset $asset, MetaDataCollection $metaDataCollection) { $nodeType = $this->nodeTypeManager->getNodeType('Neos.MetaData:Image'); $asset = $metaDataCollection->get('asset'); $assetNodeData = $this->metaDataRepository->findOneByAssetIdentifier($asset->getIdentifier(), $this->context->getWorkspace()); if ($assetNodeData === null) { $assetNodeDataTemplate = $this->createAssetNodeTemplate($asset, $nodeType); $this->mapMetaDataToNodeData($assetNodeDataTemplate, $nodeType, $metaDataCollection); $this->nodeService->findOrCreateMetaDataRootNode($this->context)->createNodeFromTemplate($assetNodeDataTemplate); } else { $this->mapMetaDataToNodeData($assetNodeData, $nodeType, $metaDataCollection); $this->metaDataRepository->update($assetNodeData); } }
/** * {@inheritdoc} * * @param FlowQuery $flowQuery the FlowQuery object * @param array $arguments the arguments for this operation * @return mixed|null if the operation is final, the return value */ public function evaluate(FlowQuery $flowQuery, array $arguments) { $imagePropertyName = $arguments[0]; if ($this->contextNode->hasProperty($imagePropertyName)) { $image = $this->contextNode->getProperty($imagePropertyName); if ($image instanceof ImageVariant) { $image = $image->getOriginalAsset(); } if ($image instanceof Image) { $identifier = $image->getIdentifier(); $nodeData = $this->metaDataRepository->findOneByAssetIdentifier($identifier, $this->contextNode->getContext()->getWorkspace()); if ($nodeData instanceof NodeData) { return $this->nodeFactory->createFromNodeData($nodeData, $this->contextNode->getContext()); } } } return null; }