本文整理汇总了PHP中Symfony\Component\HttpFoundation\RequestStack::get方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestStack::get方法的具体用法?PHP RequestStack::get怎么用?PHP RequestStack::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\RequestStack
的用法示例。
在下文中一共展示了RequestStack::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onKernelRequest
/**
* Check request to decide if user has access to specific route
*
* @param GetResponseEvent $event
* @throws AccessDeniedException
* @throws InvalidRouteException
* @throws UserNotFoundException
*/
public function onKernelRequest(GetResponseEvent $event)
{
$routeName = $event->getRequest()->get("_route");
if (strpos($routeName, "app_default_") === 0) {
throw new InvalidRouteException();
}
$routeCollection = $this->router->getRouteCollection();
$route = $routeCollection->get($routeName);
if ($route instanceof Route) {
//Check if need to validate route
//Sometime we want to allow access without validation: index page, login page
$accessValidation = $route->getOption('access_validation');
if ($accessValidation === false) {
return;
}
//Validate current user access to route
$this->authentication->setCurrentUser($this->request->get("token"));
$user = $this->authentication->getCurrentUser();
if (!$user instanceof User) {
throw new UserNotFoundException();
}
$access = $this->accessService->checkPermissions($user, $routeName);
if ($access === false) {
throw new AccessDeniedException($user, $routeName);
}
}
}
示例2: isActive
/**
* {@inheritdoc}
*/
public function isActive()
{
return $this->request->get('colorbox') !== 'no';
}