Ejemplo n.º 1
0
 /**
  * this is used to get childs below a hardlink by a path
  * for example: the requested path is /de/service/contact but /de/service is a hardlink to /en/service
  * then $hardlink would be /en/service and $path /de/service/contact and this function returns then /en/service/contact
  * @static
  * @param Document_Hardlink $hardlink
  * @param $path
  */
 public static function getChildByPath(Document_Hardlink $hardlink, $path)
 {
     if ($hardlink->getChildsFromSource() && $hardlink->getSourceDocument()) {
         $hardlinkRealPath = preg_replace("@^" . preg_quote($hardlink->getRealFullPath()) . "@", $hardlink->getSourceDocument()->getFullpath(), $path);
         $hardLinkedDocument = Document::getByPath($hardlinkRealPath);
         if ($hardLinkedDocument instanceof Document) {
             $hardLinkedDocument = Document_Hardlink_Service::wrap($hardLinkedDocument);
             $hardLinkedDocument->setHardLinkSource($hardlink);
             $_path = $path != "/" ? $_path = dirname($path) : $path;
             $_path = str_replace("\\", "/", $_path);
             // windows patch
             $_path .= $_path != "/" ? "/" : "";
             $hardLinkedDocument->setPath($_path);
             return $hardLinkedDocument;
         }
     }
     return null;
 }