Neos\ContentRepository\Domain\Utility\NodePaths::getRelativePathBetween PHP Method

getRelativePathBetween() public static method

Example with "/foo" and "/foo/bar/baz" will return "bar/baz".
public static getRelativePathBetween ( string $parentPath, string $subPath ) : string
$parentPath string
$subPath string
return string
    public static function getRelativePathBetween($parentPath, $subPath)
    {
        if (self::isSubPathOf($parentPath, $subPath) === false) {
            throw new \InvalidArgumentException('Given path "' . $parentPath . '" is not the beginning of "' . $subPath . '", cannot get a relative path between them.', 1430075362);
        }
        return trim(substr($subPath, strlen($parentPath)), '/');
    }

Usage Example

コード例 #1
0
 /**
  * Generates a Context that exactly fits the given NodeData Workspace, Dimensions & Site.
  *
  * @param NodeData $nodeData
  * @return ContentContext
  */
 protected function createContextMatchingNodeData(NodeData $nodeData)
 {
     $nodePath = NodePaths::getRelativePathBetween(SiteService::SITES_ROOT_PATH, $nodeData->getPath());
     list($siteNodeName) = explode('/', $nodePath);
     $site = $this->siteRepository->findOneByNodeName($siteNodeName);
     $contextProperties = ['workspaceName' => $nodeData->getWorkspace()->getName(), 'invisibleContentShown' => true, 'inaccessibleContentShown' => true, 'removedContentShown' => true, 'dimensions' => $nodeData->getDimensionValues(), 'currentSite' => $site];
     if ($domain = $site->getFirstActiveDomain()) {
         $contextProperties['currentDomain'] = $domain;
     }
     return $this->_contextFactory->create($contextProperties);
 }
All Usage Examples Of Neos\ContentRepository\Domain\Utility\NodePaths::getRelativePathBetween