當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Service::getDocumentIdFromHardlinkInSameSite方法代碼示例

本文整理匯總了PHP中Pimcore\Model\Document\Service::getDocumentIdFromHardlinkInSameSite方法的典型用法代碼示例。如果您正苦於以下問題:PHP Service::getDocumentIdFromHardlinkInSameSite方法的具體用法?PHP Service::getDocumentIdFromHardlinkInSameSite怎麽用?PHP Service::getDocumentIdFromHardlinkInSameSite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimcore\Model\Document\Service的用法示例。


在下文中一共展示了Service::getDocumentIdFromHardlinkInSameSite方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getFullPath

 /**
  * Returns the full path of the document including the key (path+key)
  *
  * @return string
  */
 public function getFullPath()
 {
     // check if this document is also the site root, if so return /
     try {
         if (Site::isSiteRequest()) {
             $site = Site::getCurrentSite();
             if ($site instanceof Site) {
                 if ($site->getRootDocument()->getId() == $this->getId()) {
                     return "/";
                 }
             }
         }
     } catch (\Exception $e) {
         \Logger::error($e);
     }
     // @TODO please forgive me, this is the dirtiest hack I've ever made :(
     // if you got confused by this functionality drop me a line and I'll buy you some beers :)
     // this is for the case that a link points to a document outside of the current site
     // in this case we look for a hardlink in the current site which points to the current document
     // why this could happen: we have 2 sites, in one site there's a hardlink to the other site and on a page inside
     // the hardlink there are snippets embedded and this snippets have links pointing to a document which is also
     // inside the hardlink scope, but this is an ID link, so we cannot rewrite the link the usual way because in the
     // snippet / link we don't know anymore that whe a inside a hardlink wrapped document
     if (!\Pimcore::inAdmin() && Site::isSiteRequest() && !FrontendTool::isDocumentInCurrentSite($this)) {
         $documentService = new Document\Service();
         $parent = $this;
         while ($parent) {
             if ($hardlinkId = $documentService->getDocumentIdFromHardlinkInSameSite(Site::getCurrentSite(), $parent)) {
                 $hardlink = Document::getById($hardlinkId);
                 if (FrontendTool::isDocumentInCurrentSite($hardlink)) {
                     $siteRootPath = Site::getCurrentSite()->getRootPath();
                     $siteRootPath = preg_quote($siteRootPath);
                     $hardlinkPath = preg_replace("@^" . $siteRootPath . "@", "", $hardlink->getRealFullPath());
                     return preg_replace("@^" . preg_quote($parent->getRealFullPath()) . "@", $hardlinkPath, $this->getRealFullPath());
                     break;
                 }
             }
             $parent = $parent->getParent();
         }
         $config = \Pimcore\Config::getSystemConfig();
         $front = \Zend_Controller_Front::getInstance();
         $scheme = ($front->getRequest()->isSecure() ? "https" : "http") . "://";
         if ($site = FrontendTool::getSiteForDocument($this)) {
             if ($site->getMainDomain()) {
                 // check if current document is the root of the different site, if so, preg_replace below doesn't work, so just return /
                 if ($site->getRootDocument()->getId() == $this->getId()) {
                     return $scheme . $site->getMainDomain() . "/";
                 }
                 return $scheme . $site->getMainDomain() . preg_replace("@^" . $site->getRootPath() . "/@", "/", $this->getRealFullPath());
             }
         }
         if ($config->general->domain) {
             return $scheme . $config->general->domain . $this->getRealFullPath();
         }
     }
     $path = $this->getPath() . $this->getKey();
     return $path;
 }
開發者ID:yonetici,項目名稱:pimcore-coreshop-demo,代碼行數:63,代碼來源:Document.php


注:本文中的Pimcore\Model\Document\Service::getDocumentIdFromHardlinkInSameSite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。