首页 \ 问答 \ Symfony 2.8注入RequestStack错误(Symfony 2.8 injecting RequestStack error)

Symfony 2.8注入RequestStack错误(Symfony 2.8 injecting RequestStack error)

我有注入RequestStack的问题。

在这种情况下,如果我只使用请求,一切都很好:

<?php

namespace Cms\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;

...
class DefaultController extends BaseController {
    public function mainAction(Request $request) {
...

但是,如果我尝试使用RequestStack,我会收到错误“Controller”Cms \ AdminBundle \ Controller \ DefaultController :: mainAction()“要求您为”$ requestStack“参数提供一个值(因为没有默认值或因为那里在这之后是一个非可选参数。)“

这是代码:

namespace Cms\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\RequestStack;

...
class DefaultController extends BaseController {
    public function mainAction(RequestStack $requestStack) {
...

谢谢!


I have problem with injecting RequestStack.

In this case, if I use just Request, everything is fine:

<?php

namespace Cms\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;

...
class DefaultController extends BaseController {
    public function mainAction(Request $request) {
...

But if I try to use RequestStack, I get error "Controller "Cms\AdminBundle\Controller\DefaultController::mainAction()" requires that you provide a value for the "$requestStack" argument (because there is no default value or because there is a non optional argument after this one)."

Here is the code:

namespace Cms\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\RequestStack;

...
class DefaultController extends BaseController {
    public function mainAction(RequestStack $requestStack) {
...

Thank you!


原文:
更新时间:2022-02-17 21:02

最满意答案

使用--static (额外减号),它的工作原理。


Using --static (extra minus), it works.

相关问答

更多
  • JAVA flag怎么用[2021-12-18]

    不错,再解释一下: import java.util.Scanner; public class Test50004{ public static void main(String args[]){ int ri, repeat,n; boolean flag; Scanner in=new Scanner(System.in); repeat=in.nextInt(); for(ri=1; ri<=repeat; ri++){ n=in.nextInt(); flag = prime(n); if(fla ...
  • 不要传递链接标志。 给它命名libtool存档,让automake解决它: aa_LDADD = bb/libbb.la 如果您想构建Windows DLL,您可能还想在libbb_la_LDFLAGS放置-no-undefined 。 Don't pass the link flag. Give it the name of the libtool archive and let automake work it out: aa_LDADD = bb/libbb.la In case you ever ...
  • 我可能天真地忽视了一些后果,但是你不能直接将文件视为档案吗? for i in *.a; ar x $i; done ar r libfoo.a *.o ranlib libfoo.a 当然,如果有任何.o文件是相同的,你将需要某种重命名方案。 可能类似libname_objectname.o 。 I'm probably naively ignoring some consequence, but couldn't you just treat the files directly as archive ...
  • Memcache是你的朋友。 或者看看Objectify ,它将为您处理缓存。 Memcache is your friend. Or take a look at Objectify, which will handle caching for you.
  • 我用这种方式解决了这个问题:在~/.bash_profile修改了我的PATH以export PATH="/Library/Developer/CommandLineTools/usr/bin:$PATH ,打开一个新的终端并再次运行安装过程libtool Library中的libtool / Developer / CommandLineTools / usr / bin没有抱怨-static标志,一切运行良好。您可以稍后从$PATH删除/Library/Developer/CommandLineTool ...
  • 实际上我找出了问题:这确实是由于没有fortran编译器。 正如我所说,我从Macports下载了一个包含fortran的gcc编译器: sudo port安装gcc46 + gfortran 然后我不得不将此编译器设置为我的默认编译器: 1)从Macports安装gcc_select sudo port install gcc_select 2)查看所有gcc编译器并默认将其中一个设置为编译器(我的编译器是mp-gcc46): 端口选择 - 列表gcc sudo port select --set gcc ...
  • libtool .la是一个“元数据”文件。 在构建cds2库之后,预计libtool也将在“链接”模式下用于构建任何包的测试等。 通常,在您找到.la文件的目录中,您将在.la子目录下找到.a和.so 。 如果configure被赋予--enable-static选项(或默认启用),则会在那里找到.libs/libcds2.a文件。 但是,我的理解是你已经在/opt安装了软件包: g++ -I/opt/include/ libcdsNoptrs.cpp util.cpp -o test /opt/lib/ ...
  • 是的,您可以这样做,但如果后台操作处理任何用户数据,则不应该这样做。 MacOS上的UI语法教会用户希望保存所有数据,除非他们另有说明。 由于在绝大多数情况下保存几乎是即时的(从用户的角度来看),最好向后台操作发送通知,告诉它停止并保存。 Yes, you can do that but you shouldn't if the background operation handles any user data. The UI grammar on MacOS teachers users to expe ...
  • 使用--static (额外减号),它的工作原理。 Using --static (extra minus), it works.
  • 这是一个基本的,不切实际的makefile,它将使静态库libmyLibary成为程序main ,它将使用-L (库搜索路径)和-l (库)选项与静态库链接。 Makefile文件 .PHONY: all clean all: libmyLibrary.a main main: main.o | libmyLibrary.a $(CC) -o main main.o -L. -lmyLibrary libmyLibrary.a: myLibrary.o $(AR) rcs libmyL ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。