当前位置: 首页>>代码示例>>PHP>>正文


PHP Library::getQueryParameters方法代码示例

本文整理汇总了PHP中Bolt\Library::getQueryParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Library::getQueryParameters方法的具体用法?PHP Library::getQueryParameters怎么用?PHP Library::getQueryParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bolt\Library的用法示例。


在下文中一共展示了Library::getQueryParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: contentAction

 /**
  * Perform actions on content.
  *
  * @param Application $app             The application/container
  * @param string      $action          The action
  * @param string      $contenttypeslug The content type slug
  * @param integer     $id              The content ID
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function contentAction(Application $app, $action, $contenttypeslug, $id)
 {
     if ($action === 'delete') {
         return $this->deleteContent($app, $contenttypeslug, $id);
     }
     $contenttype = $app['storage']->getContentType($contenttypeslug);
     $content = $app['storage']->getContent($contenttype['slug'] . '/' . $id);
     $title = $content->getTitle();
     // get the parameters from the URL of the previous page, so we can return to it.
     $redirectParameters = Lib::getQueryParameters($app['request']->server->get('HTTP_REFERER'));
     $redirectParameters['contenttypeslug'] = $contenttype['slug'];
     // map actions to new statuses
     $actionStatuses = array('held' => 'held', 'draft' => 'draft', 'publish' => 'published');
     // Map actions to requre permission
     $actionPermissions = array('publish' => 'publish', 'held' => 'depublish', 'draft' => 'depublish');
     if (!isset($actionStatuses[$action])) {
         $app['session']->getFlashBag()->add('error', Trans::__('No such action for content.'));
         return Lib::redirect('overview', $redirectParameters);
     }
     $newStatus = $actionStatuses[$action];
     if (!$app['users']->isAllowed("contenttype:{$contenttype['slug']}:{$actionPermissions[$action]}:{$id}") || !$app['users']->isContentStatusTransitionAllowed($content['status'], $newStatus, $contenttype['slug'], $id)) {
         $app['session']->getFlashBag()->add('error', Trans::__('You do not have the right privileges to %ACTION% that record.', array('%ACTION%' => $actionPermissions[$action])));
         return Lib::redirect('overview', $redirectParameters);
     }
     if ($app['storage']->updateSingleValue($contenttype['slug'], $id, 'status', $newStatus)) {
         $app['session']->getFlashBag()->add('info', Trans::__("Content '%title%' has been changed to '%newStatus%'", array('%title%' => $title, '%newStatus%' => $newStatus)));
     } else {
         $app['session']->getFlashBag()->add('info', Trans::__("Content '%title%' could not be modified.", array('%title%' => $title)));
     }
     return Lib::redirect('overview', $redirectParameters);
 }
开发者ID:realitygaps,项目名称:site-v20,代码行数:41,代码来源:Backend.php


注:本文中的Bolt\Library::getQueryParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。