无法在Cakephp 2.5中使用Shell中的requestAction [英] Can't use requestAction from Shell in Cakephp 2.5

查看:52
本文介绍了无法在Cakephp 2.5中使用Shell中的requestAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如前所述,当我在shell中使用时:

As stated, when I use in a shell :

$this->requestAction('/sites/zaz/option1');

该动作不会被触发.为了对此进行测试,我尝试了:

The action doesn't get triggered. To test this, I tried :

public function zaz($option1 = null) {
        CakeLog::write('acces', 'action triggered');
        return 'got it !';
    }

操作没有完成,也没有任何日志记录.我所有其他日志都可以工作.

And the action isn't done and there is no log written whatsoever. All my other logs do work.

所以我尝试了:

$this->requestAction('/sites/actionwhichdoesntexist/option1');

我收到一条错误消息,指出该操作不存在.

And I got an error stating that the action doesn't exist.

我确实需要使用requestAction,因为我有一个模型/控制器,并且此操作通常用于测试资源是否仍在运行.我想使用requestAction来顺利处理"requested"方面,以便构建更强大的功能:

I really need to use requestAction, because I have a model/controller and this action is typically testing that a ressource is still alive. I want to use requestAction in order to smoothly handle the "requested" aspect, so that I will build something more robust :

if(empty($this->request->params['requested']))
            $this->redirect(array('controller'=>'proxies', 'action'=>'index', 'admin'=>true));
        else
            return true;

我尝试使用2.4.1和2.5,即使我在操作中添加了"die()",也不会发生任何事情,也不会给出任何输出.

I tried with 2.4.1 and 2.5, nothing just happens, no output is given, even if I put a 'die()' in the action.

推荐答案

如第一条评论所述,我应该已经检查过beforeFilter函数.

As stated in the first comment, I should have checked the beforeFilter function.

这篇关于无法在Cakephp 2.5中使用Shell中的requestAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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