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


PHP UrlHelper::getUrlWithToken方法代碼示例

本文整理匯總了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);
 }
開發者ID:kentonquatman,項目名稱:portfolio,代碼行數:49,代碼來源:EntriesController.php

示例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);
 }
開發者ID:jmstan,項目名稱:craft-website,代碼行數:26,代碼來源:CategoriesController.php

示例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);
 }
開發者ID:aladrach,項目名稱:Bluefoot-Craft-Starter,代碼行數:24,代碼來源:SproutEmail_EntryController.php


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