蛋糕 2 外壳:未定义的方法成功()


Cake 2 Shell: Undefined method success()

我写了一个使用Cake-Shell方法"success()"的Cake-Shell,但这被声明为未定义。我在网络上找不到任何描述该问题的线程。我可以说几周前贝壳确实运行良好。

方法调用:

$this->success('success', array());

我通过以下方式调用 Windows-CLI 中的外壳

cake ImportItems

显然贯穿它,但在应该触发 $this->success() 时抛出错误:

致命错误:调用未定义的方法 ImportItemsShell::success() in D:''xampp''htdocs''myCake''app''Console''Command''ImportItemsShell.php 在第 29 行

这是我的外壳代码

require_once('libraries/Ini.php');
class ImportItemsShell extends AppShell {
/**
 * Main fn
 */
public function main() {
    $this->importItems();
}
/**
 * Get called by Cron
 */
protected function importItems() {
    $Shop= new Shop(SHOP_DB); 
    $items = Api::getItems(true);
    $mysql = MySQL::getInstance();
    $res = array();
    if(is_array($items) && ($items['status'] == Api::STATUS_OK)) {
        $Shop->importItems($items['values']);
        $this->success('success', $items['values']);
    } else {
        $this->error('invalid_item_response', array());
    }
}
}

错误是正确的,Cake 2.x 中没有Shell::success()方法。与可以使用Shell::error()Shell::err()写入stderr的错误相反,"成功"消息将简单地写入Shell::out() stdout

也许只是您的错误报告设置发生了变化?

有关详细信息,请参阅 http://book.cakephp.org/2.0/en/console-and-shells.html。