public getNodeFromContextPath ( string $contextPath, TYPO3\Neos\Domain\Model\Site $site = null, TYPO3\Neos\Domain\Model\Domain $domain = null ) : TYPO3\TYPO3CR\Domain\Model\NodeInterface | ||
$contextPath | string | |
$site | TYPO3\Neos\Domain\Model\Site | |
$domain | TYPO3\Neos\Domain\Model\Domain | |
return | TYPO3\TYPO3CR\Domain\Model\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);
}
/** * Convert array to change interface * * @param array $changeData * @return ChangeInterface */ protected function convertChangeData($changeData) { $type = $changeData['type']; if (!isset($this->typeMap[$type])) { return new \TYPO3\Flow\Error\Error(sprintf('Could not convert change type %s, it is unknown to the system', $type)); } $changeClass = $this->typeMap[$type]; $changeClassInstance = $this->objectManager->get($changeClass); $subjectContextPath = $changeData['subject']; $subject = $this->nodeService->getNodeFromContextPath($subjectContextPath); if ($subject instanceof \TYPO3\Flow\Error\Error) { return $subject; } $changeClassInstance->setSubject($subject); if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) { $referenceContextPath = $changeData['reference']; $reference = $this->nodeService->getNodeFromContextPath($referenceContextPath); if ($reference instanceof \TYPO3\Flow\Error\Error) { return $reference; } $changeClassInstance->setReference($reference); } if (isset($changeData['payload'])) { foreach ($changeData['payload'] as $key => $value) { if (!in_array($key, $this->disallowedPayloadProperties)) { ObjectAccess::setProperty($changeClassInstance, $key, $value); } } } return $changeClassInstance; }