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