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