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