<?php
namespace Moto\System; use Moto; use Zend; class Event { const SYSTEM_BOOTSTRAP_BEFORE = 'system.bootstrap:before'; const SYSTEM_BOOTSTRAP = 'system.bootstrap'; const SYSTEM_BOOTSTRAP_AFTER = 'system.bootstrap:after'; const SYSTEM_SHUTDOWN = 'system.shutdown'; const USER_DELETE = 'user.delete'; const CACHE_CLEAN = 'cache.clean'; const _PRIORITY_DEFAULT = 50; protected static $_firewall = null; protected static $_initialized = false; public static function init() { if (static::$_initialized) { return; } static::$_initialized = true; } public static function getFirewall() { if (null === static::$_firewall) { static::$_firewall = new Event\Firewall(); } return static::$_firewall; } public static function getEventManager() { return Moto\Hook::getEventManager(); } public static function attach($event, $callback = null, $priority = null) { return Moto\Hook::on($event, $callback, $priority); } public static function attachSolo($event, $callback = null, $priority = null) { return Moto\Hook::once($event, $callback, $priority); } public static function trigger($event, $target = null, $argv = array(), $callback = null) { $result = null; try { $result = Moto\Hook::getEventManager()->filter($event, $target, $argv); } catch(\Exception $e) { Moto\System\Log::error('Moto\System\Event::trigger', array('event' => $event, 'code' => $e->getCode(), 'message' => $e->getMessage())); } return $result; } }