logikostech/events
Composer 安装命令:
composer require logikostech/events
包简介
Events helper for phalcon php projects
README 文档
README
Logikos\Events\EventsAwareTrait
Useful trait when using Phalcon\Events\EventsAwareInterface. Key feature is the attachEventListener method in that if an EventsManager is not yet being used by the component it will add one and then attach the event. This way you don't have to setup your events manager when you setup the \Phalcon\Di services and each controller or library using the componenet can attach their own events as they see fit on a case by case basis.
Usage
Add to class
class foo implements \Phalcon\Events\EventsAwareInterface { use \Logikos\Events\EventsAwareTrait; }
Add event handelers with ease
To listen for all events pass null
$component->attachEventListener(null, function(\Phalcon\Events\Event $event, $component, $data=null) { switch ($event->getType()) { case 'beforeAction' : // ... break; case 'afterAction' : // ... break; } });
Listen for specific event
$component->attachEventListener('beforeAction', function(\Phalcon\Events\Event $event, $component, $data=null) { // ... });
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-09