/** * Declare the session as “expired”. It will fire an event on * static::EVENT_CHANNEL . $namespace . ':expired' if this channel is * listened, else it will throw an exception. Moreover, it will * re-initialize the namespace. * * @param bool $exception Whether throw an exception if needed or not. * @return void * @throws \Hoa\Session\Exception\Expired * @throws \Hoa\Session\Exception\Locked */ public function hasExpired($exception = true) { $namespace = $this->getNamespace(); if (true === $this->isLocked()) { throw new Exception\Locked('Namespace %s is locked because it has been unset.', 4, $namespace); } $this->initialize(true); $expired = static::EVENT_CHANNEL . $namespace . ':expired'; if (true === $exception && false === event($expired)->isListened()) { throw new Exception\Expired('Namespace %s has expired. All data belonging to this ' . 'namespace are lost.', 5, $namespace); } Core\Event::notify($expired, $this, new Core\Event\Bucket()); return; }
/** * Close the current stream. * * @return void */ public final function close() { $streamName = $this->getStreamName(); $name = md5($streamName); if (!isset(self::$_register[$name])) { return; } Core\Event::notify('hoa://Event/Stream/' . $streamName . ':close-before', $this, new Core\Event\Bucket()); if (false === $this->_close()) { return; } unset(self::$_register[$name]); $this->_bucket[self::HANDLER] = null; unset($this->_on); Core\Event::unregister('hoa://Event/Stream/' . $streamName); Core\Event::unregister('hoa://Event/Stream/' . $streamName . ':close-before'); return; }
/** * Log a message with a type. * * @access public * @param string $message The log message. * @param int $type Type of message (please, see the class * constants). * @param array $extra Extra dynamic informations. * @return void */ public function log($message, $type = self::DEBUG, $extra = array()) { $filters = $this->getFilters(); if (null !== $filters && !($type & $filters)) { return; } $handle = $this->_stack[] = array_merge(array(self::STACK_TIMESTAMP => microtime(true), self::STACK_MESSAGE => $message, self::STACK_PRIORITY => $type, self::STACK_MEMORY => memory_get_usage(), self::STACK_MEMORY_PEAK => memory_get_peak_usage()), $this->getAddedStackInformations(), $extra); \Hoa\Core\Event::notify('hoa://Event/Log/' . self::$_currentId, $this, new \Hoa\Core\Event\Bucket(array('log' => $handle))); if ($type & self::DEBUG) { if (null === $this->_backtrace) { $this->_backtrace = new Backtrace(); } $this->_backtrace->debug(); } return; }
/** * Close connection to the database. * * @return bool */ public function close() { $id = $this->getId(); $event = 'hoa://Event/Database/' . $id; $this->_layer = null; self::$_id = null; unset(self::$_instance[$id]); Core\Event::notify($event . ':closed', $this, new Core\Event\Bucket(['id' => $id])); Core\Event::unregister($event . ':opened'); Core\Event::unregister($event . ':closed'); return true; }
/** * Send the exception on hoa://Event/Exception. * * @return void */ public function send() { Core\Event::notify('hoa://Event/Exception', $this, new Core\Event\Bucket($this)); return; }
* @return void */ public static function copy($data) { if (OS_WIN) { return; } echo "]52;;" . base64_encode($data) . "\\"; return; } } } namespace { /** * Advanced interaction. */ \Hoa\Console::advancedInteraction(); /** * Event. */ if (function_exists('pcntl_signal')) { \Hoa\Console\Window::getInstance(); pcntl_signal(SIGWINCH, function () { static $_window = null; if (null === $_window) { $_window = \Hoa\Console\Window::getInstance(); } \Hoa\Core\Event::notify('hoa://Event/Console/Window:resize', $_window, new \Hoa\Core\Event\Bucket(array('size' => \Hoa\Console\Window::getSize()))); }); } }
* Set clipboard value. * * @param string $data Data to copy. * @return void */ public static function copy($data) { if (OS_WIN) { return; } echo "]52;;" . base64_encode($data) . "\\"; return; } } /** * Advanced interaction. */ Console::advancedInteraction(); /** * Event. */ if (function_exists('pcntl_signal')) { Window::getInstance(); pcntl_signal(SIGWINCH, function () { static $_window = null; if (null === $_window) { $_window = Window::getInstance(); } Core\Event::notify('hoa://Event/Console/Window:resize', $_window, new Core\Event\Bucket(['size' => \Window::getSize()])); }); }