本文整理汇总了PHP中TYPO3\CMS\Frontend\Page\PageRepository::getPageIdFromAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP PageRepository::getPageIdFromAlias方法的具体用法?PHP PageRepository::getPageIdFromAlias怎么用?PHP PageRepository::getPageIdFromAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\Page\PageRepository
的用法示例。
在下文中一共展示了PageRepository::getPageIdFromAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrlStr
/**
* generates a string for the URL
*
* @param array $uParts the parts of the URL
* @return string the URL string
*/
function getUrlStr($uParts)
{
$baseURL = $this->getBaseURL();
if (is_array($uParts) && GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') == $uParts['host']) {
$m = array();
// do we have an id?
if (preg_match('/(?:^|&)id=([0-9a-z_]+)/', $uParts['query'], $m)) {
$isInt = MathUtility::canBeInterpretedAsInteger($m[1]);
if ($isInt) {
$uid = intval($m[1]);
} else {
$uid = $this->sys_page->getPageIdFromAlias($m[1]);
}
$temp_root_line = $this->sys_page->getRootLine($uid);
$temp_page = array_shift($temp_root_line);
// array_shift reverses the array (rootline has numeric index in the wrong order!)
$temp_root_line = array_reverse($temp_root_line);
$query = preg_replace('/(?:^|&)id=([0-9a-z_]+)/', '', $uParts['query']);
$urlstr = GeneralUtility::fixed_lgd_cs($temp_page['title'], 50) . GeneralUtility::fixed_lgd_cs($query ? ' / ' . $query : '', 20);
} else {
$urlstr = $baseURL . substr($uParts['path'], 1);
$urlstr .= $uParts['query'] ? '?' . $uParts['query'] : '';
$urlstr .= $uParts['fragment'] ? '#' . $uParts['fragment'] : '';
}
} else {
$urlstr = ($uParts['host'] ? $uParts['scheme'] . '://' . $uParts['host'] : $baseURL) . $uParts['path'];
$urlstr .= $uParts['query'] ? '?' . $uParts['query'] : '';
$urlstr .= $uParts['fragment'] ? '#' . $uParts['fragment'] : '';
}
return $urlstr;
}
示例2: fixPageId
/**
* Fixes page id if it is not a direct numeric page id.
*/
protected function fixPageId()
{
if (!MathUtility::canBeInterpretedAsInteger($this->urlParameters['id'])) {
// Seems to be an alias
$alias = $this->urlParameters['id'];
$this->urlParameters['id'] = $this->pageRepository->getPageIdFromAlias($alias);
if ($this->urlParameters['id'] === 0) {
throw new \Exception(sprintf('Page with alias "%s" does not exist.', $alias), 1457183797);
}
}
}
示例3: checkAndSetAlias
/**
* Fetches the integer page id for a page alias.
* Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id
*
* @return void
* @access private
* @todo Define visibility
*/
public function checkAndSetAlias()
{
if ($this->id && !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->id)) {
$aid = $this->sys_page->getPageIdFromAlias($this->id);
if ($aid) {
$this->id = $aid;
} else {
$this->pageNotFound = 4;
}
}
}