Book: http://book.cakephp.org/2.0/en/core-libraries/events.html
Trying to get to grips with one of the new features of CakePHP 2.1. Have
read the above page in the book and want to implement the code shown in the
'Registering Listeners' section but no indication given as to where the
following code goes:
App::uses('CakeEventListener', 'Event');class UserStatistic implements
CakeEventListener {
public function implementedEvents() {
return array(
'Model.Order.afterPlace' => 'updateBuyStatistic',
);
}
public function updateBuyStatistic($event) {
// Code to update statistics
}}
What I need to know is
- What the file should be named
- What folder it should reside in
- How I include it in the app
I assume the following goes in the Order controller, but not confident:
// Attach the UserStatistic object to the Order's event manager$statistics =
new UserStatistic;$this->Order->getEventManager($statistics);
If anyone can make sense of it and give me some pointers I would
much appreciate it.
Here's someone asking the same question on CakePHP Questions:
http://ask.cakephp.org/questions/view/cakephp_2_1_global_events_system
Paul.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php