public function convertUriToObject($uri, NodeInterface $contextNode = null)
{
if ($uri instanceof Uri) {
$uri = (string) $uri;
}
if (preg_match(self::PATTERN_SUPPORTED_URIS, $uri, $matches) === 1) {
switch ($matches[1]) {
case 'node':
if ($contextNode === null) {
throw new \RuntimeException('node:// URI conversion requires a context node to be passed', 1409734235);
}
return $contextNode->getContext()->getNodeByIdentifier($matches[2]);
case 'asset':
return $this->assetRepository->findByIdentifier($matches[2]);
}
}
return null;
}