当前位置: 首页>>代码示例>>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;未经允许,请勿转载。