/** * Constructor * * @param string|null $class The class of the object that uses this event dispatcher (if any) */ public function __construct($class = null) { if (null === $class) { $class = get_class($this); } $this->_class = sprintf('%s#%d', $class, ++self::$_instances); $this->setRegistry(Streamwide_Engine_Registry::getInstance()); }
/** * Retrieve the next signal from the SW Engine's event queue * * @param array $options * @return Streamwide_Engine_Signal|boolean */ public static function dequeue(array $options = null) { $registry = Streamwide_Engine_Registry::getInstance(); // initialize options to their default values if (null === ($engineProxy = $registry->get(SW_ENGINE_PROXY))) { $engineProxy = new Streamwide_Engine_Proxy(); $registry->set(SW_ENGINE_PROXY, $engineProxy); } $timeout = -1; $savePhpId = true; if (is_array($options)) { if (isset($options['timeout'])) { $timeout = (int) $options['timeout']; } if (isset($options['engineProxy']) && $options['engineProxy'] instanceof Streamwide_Engine_Proxy) { $engineProxy = $options['engineProxy']; $registry->set(SW_ENGINE_PROXY, $engineProxy); } if (isset($options['savePhpId'])) { $savePhpId = (bool) $options['savePhpId']; } } if (false === ($array = $engineProxy->nextEvent($timeout))) { return false; } $name = $array[self::SIG_NAME]; $phpId = $array[self::SIG_PHPID]; $remote = $array[self::SIG_REMOTE]; $params = $array[self::SIG_PARAMS]; if ($savePhpId) { $registry->set(SW_ENGINE_CURRENT_PHPID, $phpId); } $signal = new self($engineProxy); $signal->setName($name); $signal->setPhpId($phpId); $signal->setRemote($remote); $signal->setParams($params); return $signal; }
/** * Constructor */ public function __construct() { $this->setEventDispatcher(new self::$_defaultEventDispatcherClass(get_class($this))); $this->setRegistry(Streamwide_Engine_Registry::getInstance()); }
/** * Set a logger to be used by this class * * @param Streamwide_Log $log * @param boolean $overwrite * @return void */ public static function setLog(Streamwide_Log $log, $overwrite = true) { $self = self::_getInstance(); if (null !== $self->_log && false === $overwrite) { return null; } if (defined('SW_ENGINE_LOG')) { $registry = Streamwide_Engine_Registry::getInstance(); $registry->set(SW_ENGINE_LOG, $log); } $self->_log = $log; }