如何以编程方式创建CakeRequest的实例? [英] How to programmatically create instance of CakeRequest?

查看:223
本文介绍了如何以编程方式创建CakeRequest的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Lib目录中有Api类。这个类有'request'作为唯一的方法。此方法接受CakeRequest作为参数之一。这个Api方法从UI通过组件调用,这是工作正常。

I have Api class in Lib directory. This class have 'request' as the only method. This method accepts CakeRequest as one of the arguments. This Api method is called from UI through a component, which is working fine.

现在,我需要创建一个控制台shell,并调用同样的Api方法(Api :: request)。如何创建CakeRequest的实例,以便它可以作为参数传递?

Now, I need to create a console shell, and make a call to this same Api method (Api::request). How to create instance of CakeRequest, so that it can be passed as argument?

推荐答案

不知道这是什么寻找,但你可以简单地使用:

Not sure if this is what you're looking for, but you can simply use:

$request = new CakeRequest();

,然后您可以传递 $ request 变量作为参数。

and then you can pass the $request variable as argument.

这与Cake在使用 Dispatcher :: dispatch(new CakeRequest ())

这篇关于如何以编程方式创建CakeRequest的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆