public function getIncludeRelationships($path, $type)
{
// check if it's in cache
if (isset($this->includeRelationshipsCache[$type][$path]) === true) {
return $this->includeRelationshipsCache[$type][$path];
}
$includePaths = $this->getIncludePathsByType($type);
$pathBeginning = (string) $path;
$pathLength = strlen($pathBeginning);
$result = [];
foreach ($includePaths as $curPath) {
if ($pathLength === 0) {
$relationshipName = $this->getRelationshipNameForTopResource($curPath);
} elseif (strpos($curPath, $pathBeginning . DocumentInterface::PATH_SEPARATOR) === 0) {
$relationshipName = $this->getRelationshipNameForResource($curPath, $pathLength);
} else {
$relationshipName = null;
}
// add $relationshipName to $result if not yet there
if ($relationshipName !== null && isset($result[$relationshipName]) === false) {
$result[$relationshipName] = $relationshipName;
}
}
$this->includeRelationshipsCache[$type][$path] = $result;
return $result;
}