【发布时间】:2015-03-03 02:28:58
【问题描述】:
尝试从 CakePHP 的 EventListener 开始。我已经设置了一个事件,但它没有触发。我想不通为什么?这是我到目前为止的代码......
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”事件?
-
我的错...
标签: cakephp cakephp-3.0