-
Notifications
You must be signed in to change notification settings - Fork 39
EventManager
AntonShevchuk edited this page Mar 20, 2012
·
9 revisions
Менеджер событий - ничего военного.
нет
<?php
$app->getEventManager()
->attach('testevent', function(Event $event){
return $event->getTarget()*2;
})
->attach('testevent', function(Event $event){
return $event->getTarget()*2;
});
$app->getEventManager()->attach('testspace:event', function(Event $event){
return $event->getTarget()+4;
});
$app->getEventManager()->attach('testspace:event', function(Event $event){
return $event->getTarget()+2;
});
$app->getEventManager()->attach('testspace:event2', function(Event $event){
$event->setTarget($event->getTarget()+5);
return false; // stop propogation
});
$app->getEventManager()->attach('testspace:event2', function(Event $event){
echo "Never run";
});
$app->getEventManager()->attach('testspace', function(Event $event){
return $event->getTarget()+1;
});
$res1 = $app->getEventManager()->trigger('testevent', 1, array(1,2,3)); // 1*2*2 = 4
$res2 = $app->getEventManager()->trigger('testspace:event', 1, array(1,2,3)); // 1+1+4+2 = 8
$res3 = $app->getEventManager()->trigger('testspace:event2', 1, array(1,2,3)); // 1+1+5 = 7
- log - используем для профайлера
- view:header
- view:content
- view:footer
Acl
Application
Auth
Cache
Common
— Exception
— Collection
— Container
— Helper
— Options
— Singleton
Config
Controller
— Data
— Mapper
—— Crud
—— Rest
— Reflection
Crud
— Crud Table
Db
— Row
— Table
— Relations
— Query
Debug
EventManager
Grid
Http
Layout
Logger
Mailer
Messages
Nil
Proxy
Registry
Request
Response
Router
Session
Translator
Validator
View