/** * Command handler * * @param string The command name * @param object The command context * @return boolean Always returns true */ public function execute($name, KCommandContext $context) { $type = ''; if ($context->caller) { $identifier = clone $context->caller->getIdentifier(); if ($identifier->path) { $type = array_shift($identifier->path); } else { $type = $identifier->name; } } $parts = explode('.', $name); $event = 'on' . ucfirst(array_shift($parts)) . ucfirst($type) . KInflector::implode($parts); $this->_dispatcher->dispatchEvent($event, clone $context); return true; }
/** * Dispatches an event by dispatching arguments to all listeners that handle * the event and returning their return values. * * This function will add a mark to the profiler for each event dispatched * * @param string The event name * @param object|array An array, a KConfig or a KEvent object * @return KEventDispatcher */ public function dispatchEvent($name, $event = array()) { $this->_events[] = array( 'message' => $name, 'time' => $this->getElapsedTime(), 'memory' => $this->getMemory(), 'caller' => $event->caller->getIdentifier() ); return parent::dispatchEvent($name, $event); }