0
嘗試從CakePHP的EventListener開始。我已經設定了一個事件,但它並沒有開火。我無法弄清楚爲什麼?這是我到目前爲止的代碼...CakePHP 3 - 已實現的事件() - 未觸發已實施的事件
public function view($slug = null) {
$profile = $this->Profiles->find()->where(['slug' => $slug])->first();
$this->set('profile', $profile);
$this->set('_serialize', ['profile']);
}
// I have confirmed this works.. but it is not calling the updateCountEvent method
public function implementedEvents(){
$_events = parent::implementedEvents();
$events['Controller.afterView'] = 'updateCountEvent';
return array_merge($_events, $events);
}
/**
* Triggered when a profile is viewed...
*/
public function updateCountEvent(){
Log::write('error', "Update count events"); // I dont get this line in the log. Not sure why this does not fire...
}
你在哪裏觸發「afterView」事件? – 2015-03-03 08:28:30
我的壞..我認爲implementsEvents()行動將觸發它....我現在會重新審視... – 2015-03-03 16:41:12