2013-10-30 39 views
0

我寫了一個使用Cake-Shell方法「success()」的Cake-Shell,但是這被聲明爲undefined。我無法找到描述該問題的任何線程。我可以說殼幾周前運行得很好。Cake 2 Shell:未定義方法成功()

方法調用:

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

我打電話通過

cake ImportItems 

及其顯然通過它運行,但拋出一個錯誤在我的Windows的命令行外殼時,應解僱$這個 - >成功():

Fatal error: Call to undefined method ImportItemsShell::success() in D:\xampp\htdocs\myCake\app\Console\Command\ImportItemsShell.php on line 29

這裏是我的殼牌

準則10
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()); 
    } 
} 
} 

回答

1

錯誤是正確的,在Cake 2.x中沒有Shell::success()方法。與可以使用Shell::error()Shell::err()寫入stderr的錯誤相比,可以使用Shell::out()簡單地將「成功」消息寫入stdout

也許這只是您的錯誤報告設置已更改?

查看http://book.cakephp.org/2.0/en/console-and-shells.html瞭解更多信息。