本文整理汇总了PHP中UrlHelper::getUrlWithToken方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::getUrlWithToken方法的具体用法?PHP UrlHelper::getUrlWithToken怎么用?PHP UrlHelper::getUrlWithToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlHelper
的用法示例。
在下文中一共展示了UrlHelper::getUrlWithToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionShareEntry
/**
* Redirects the client to a URL for viewing an entry/draft/version on the front end.
*
* @param mixed $entryId
* @param mixed $locale
* @param mixed $draftId
* @param mixed $versionId
*
* @throws HttpException
* @return null
*/
public function actionShareEntry($entryId = null, $locale = null, $draftId = null, $versionId = null)
{
if ($entryId) {
$entry = craft()->entries->getEntryById($entryId, $locale);
if (!$entry) {
throw new HttpException(404);
}
$params = array('entryId' => $entryId, 'locale' => $entry->locale);
} else {
if ($draftId) {
$entry = craft()->entryRevisions->getDraftById($draftId);
if (!$entry) {
throw new HttpException(404);
}
$params = array('draftId' => $draftId);
} else {
if ($versionId) {
$entry = craft()->entryRevisions->getVersionById($versionId);
if (!$entry) {
throw new HttpException(404);
}
$params = array('versionId' => $versionId);
} else {
throw new HttpException(404);
}
}
}
// Make sure they have permission to be viewing this entry
$this->enforceEditEntryPermissions($entry);
// Make sure the entry actually can be viewed
if (!craft()->sections->isSectionTemplateValid($entry->getSection())) {
throw new HttpException(404);
}
// Create the token and redirect to the entry URL with the token in place
$token = craft()->tokens->createToken(array('action' => 'entries/viewSharedEntry', 'params' => $params));
$url = UrlHelper::getUrlWithToken($entry->getUrl(), $token);
craft()->request->redirect($url);
}
示例2: actionShareCategory
/**
* Redirects the client to a URL for viewing a disabled category on the front end.
*
* @param mixed $categoryId
* @param mixed $locale
*
* @throws HttpException
* @return null
*/
public function actionShareCategory($categoryId, $locale = null)
{
$category = craft()->categories->getCategoryById($categoryId, $locale);
if (!$category) {
throw new HttpException(404);
}
// Make sure they have permission to be viewing this category
$this->_enforceEditCategoryPermissions($category);
// Make sure the category actually can be viewed
if (!craft()->categories->isGroupTemplateValid($category->getGroup())) {
throw new HttpException(404);
}
// Create the token and redirect to the category URL with the token in place
$token = craft()->tokens->createToken(array('action' => 'categories/viewSharedCategory', 'params' => array('categoryId' => $categoryId, 'locale' => $category->locale)));
$url = UrlHelper::getUrlWithToken($category->getUrl(), $token);
craft()->request->redirect($url);
}
示例3: actionShareEntry
/**
* Redirects the client to a URL for viewing an entry/draft on the front end.
*
* @param mixed $entryId
*
* @throws HttpException
* @return null
*/
public function actionShareEntry($entryId = null)
{
if ($entryId) {
$entry = sproutEmail()->entries->getEntryById($entryId);
if (!$entry) {
throw new HttpException(404);
}
$params = array('entryId' => $entryId);
} else {
throw new HttpException(404);
}
// Create the token and redirect to the entry URL with the token in place
$token = craft()->tokens->createToken(array('action' => 'sproutEmail/entry/viewSharedEntry', 'params' => $params));
$url = UrlHelper::getUrlWithToken($entry->getUrl(), $token);
craft()->request->redirect($url);
}