本文整理汇总了PHP中Symfony\Component\HttpFoundation\RequestStack::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestStack::getSession方法的具体用法?PHP RequestStack::getSession怎么用?PHP RequestStack::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\RequestStack
的用法示例。
在下文中一共展示了RequestStack::getSession方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param Request|RequestStack $requestStack A RequestStack instance or a Request instance
*
* @deprecated since 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0
*/
public function __construct($requestStack)
{
if ($requestStack instanceof Request) {
$this->session = $requestStack->getSession();
} elseif ($requestStack instanceof RequestStack) {
$this->requestStack = $requestStack;
} else {
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
}
}
示例2: __construct
/**
* Constructor.
*
* @param Request|RequestStack $requestStack A RequestStack instance or a Request instance
*
* @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0.
*/
public function __construct($requestStack)
{
if ($requestStack instanceof Request) {
@trigger_error('Since version 2.5, passing a Request instance into the ' . __METHOD__ . ' is deprecated and support for it will be removed in 3.0. Inject a Symfony\\Component\\HttpFoundation\\RequestStack instance instead.', E_USER_DEPRECATED);
$this->session = $requestStack->getSession();
} elseif ($requestStack instanceof RequestStack) {
$this->requestStack = $requestStack;
} else {
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
}
}