/** * @param string $path * @return void */ protected function getNearestDocumentByPath($path, $ignoreHardlinks = false) { if ($this->nearestDocumentByPath instanceof Document) { $document = $this->nearestDocumentByPath; } else { $pathes = array(); $pathes[] = "/"; $pathParts = explode("/", $path); $tmpPathes = array(); foreach ($pathParts as $pathPart) { $tmpPathes[] = $pathPart; $t = implode("/", $tmpPathes); if (!empty($t)) { $pathes[] = $t; } } $pathes = array_reverse($pathes); foreach ($pathes as $p) { if ($document = Document::getByPath($p)) { $this->nearestDocumentByPath = $document; break; } } } if ($document) { if (!$ignoreHardlinks) { if ($document instanceof Document_Hardlink) { if ($hardLinkedDocument = Document_Hardlink_Service::getChildByPath($document, $path)) { $document = $hardLinkedDocument; } else { $document = Document_Hardlink_Service::wrap($document); } } } return $document; } return null; }