/**
  * @param JoinPointInterface $joinPoint
  * @Flow\After("method(TYPO3\TypoScript\Core\Runtime->pushContextArray())")
  * @return void
  */
 public function extendContextWithMetaDataRootNode(JoinPointInterface $joinPoint)
 {
     /** @var \TYPO3\TypoScript\Core\Runtime $runtime */
     $runtime = $joinPoint->getProxy();
     $currentContext = $runtime->getCurrentContext();
     if (isset($currentContext['node'])) {
         /** @var \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node */
         $node = $currentContext['node'];
         $metaDataRootNode = $this->nodeService->findOrCreateMetaDataRootNode($node->getContext());
         $currentContext = $runtime->popContext();
         $currentContext[MetaDataRepository::METADATA_ROOT_NODE_NAME] = $metaDataRootNode;
         $runtime->pushContextArray($currentContext);
     }
 }
 /**
  * @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);
     }
 }