当我想添加一些自定义标头(在我的情况下为|| )时,我有函数onKernelRequest并且我可以得到该标头但是当我在注释上尝试它时失败:api=true
$request->headers->set('api', "true")
Request $request
- onKernelRequest:
public function onKernelRequest(RequestEvent $event)
{
if (!$event->isMasterRequest()) { return; }
$request = $event->getRequest();
$request->headers->set('api', "true");
return;
}
- 路线
/* @Route(
* "/user/info/",
* name="get_user_info",
* methods={"GET"},
* condition="request.headers.get('api')"
* )
- 错误
Path almost matches, but Condition "request.headers.get('api')" does not evaluate to "true"