本文整理匯總了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);
}