protected function getFetchPath($absPath, $class)
{
$absPath = PathHelper::normalizePath($absPath);
if (!isset($this->objectsByPath[$class])) {
$this->objectsByPath[$class] = array();
}
$op = end($this->operationsLog);
while ($op) {
if ($op instanceof MoveNodeOperation) {
if ($absPath === $op->srcPath) {
throw new ItemNotFoundException("Path not found (moved in current session): {$absPath}");
}
if (strpos($absPath, $op->srcPath . '/') === 0) {
throw new ItemNotFoundException("Path not found (parent node {$op->srcPath} moved in current session): {$absPath}");
}
if (strpos($absPath, $op->dstPath . '/') === 0 || $absPath == $op->dstPath) {
$absPath = substr_replace($absPath, $op->srcPath, 0, strlen($op->dstPath));
}
} elseif ($op instanceof RemoveNodeOperation || $op instanceof RemovePropertyOperation) {
if ($absPath === $op->srcPath) {
throw new ItemNotFoundException("Path not found (node deleted in current session): {$absPath}");
}
if (strpos($absPath, $op->srcPath . '/') === 0) {
throw new ItemNotFoundException("Path not found (parent node {$op->srcPath} deleted in current session): {$absPath}");
}
} elseif ($op instanceof AddNodeOperation) {
if ($absPath === $op->srcPath) {
// we added this node at this point so no more sanity checks needed.
return $absPath;
}
}
$op = prev($this->operationsLog);
}
return $absPath;
}