本文整理汇总了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;
}