/**
  * Converts a given context path to a node object
  *
  * @param string $contextPath
  * @return NodeInterface
  */
 public function getNodeFromContextPath($contextPath, Site $site = null, Domain $domain = null)
 {
     $nodePathAndContext = NodePaths::explodeContextPath($contextPath);
     $nodePath = $nodePathAndContext['nodePath'];
     $workspaceName = $nodePathAndContext['workspaceName'];
     $dimensions = $nodePathAndContext['dimensions'];
     $contextProperties = $this->prepareContextProperties($workspaceName, $dimensions);
     if ($site === null) {
         list(, , $siteNodeName) = explode('/', $nodePath);
         $site = $this->siteRepository->findOneByNodeName($siteNodeName);
     }
     if ($domain === null) {
         $domain = $this->domainRepository->findOneBySite($site);
     }
     $contextProperties['currentSite'] = $site;
     $contextProperties['currentDomain'] = $domain;
     $context = $this->contextFactory->create($contextProperties);
     $workspace = $context->getWorkspace(false);
     if (!$workspace) {
         return new \TYPO3\Flow\Error\Error(sprintf('Could not convert the given source to Node object because the workspace "%s" as specified in the context node path does not exist.', $workspaceName), 1451392329);
     }
     return $context->getNode($nodePath);
 }