本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::getCurrentRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getCurrentRequest方法的具体用法?PHP Request::getCurrentRequest怎么用?PHP Request::getCurrentRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::getCurrentRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onKernelRequest
/**
* Set the ip by listening on core.request.
*
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
if (null === $this->requestStack) {
return;
}
$request = $this->requestStack->getCurrentRequest();
if (null === $request) {
return;
}
$ip = $request->getClientIp();
if (null !== $ip) {
$this->ipTraceableListener->setIpValue($ip);
}
}
示例2: getCurrentRequest
private function getCurrentRequest()
{
if (null !== $this->requestStack) {
if ($this->requestStack instanceof Request) {
return $this->requestStack;
} else {
return $this->requestStack->getCurrentRequest();
}
}
return $this->container->get('request');
}
示例3: getRequest
/**
* Returns the current Request.
*
* @return Request
*/
protected function getRequest()
{
return $this->requestStack->getCurrentRequest();
}
示例4: setRequest
/**
* @param RequestStack|Request $requestStack
*/
public function setRequest($requestStack)
{
if ($requestStack instanceof Request) {
$this->request = $requestStack;
} elseif ($requestStack instanceof RequestStack) {
$this->request = $requestStack->getCurrentRequest();
} else {
throw new \InvalidArgumentException('Argument 1 should be an instance of Symfony\\Component\\HttpFoundation\\RequestStack or Symfony\\Component\\HttpFoundation\\Request');
}
}
示例5: setRequest
/**
* @param RequestStack|Request $requestStack
*/
public function setRequest($requestStack)
{
if ($requestStack instanceof Request) {
$this->request = $requestStack;
} elseif ($requestStack instanceof RequestStack) {
$this->request = $requestStack->getCurrentRequest();
}
}