/** * Tests setCustomCommand(). */ public function testSetCustomCommand() { $command = 'foo'; $this->event->setCustomCommand($command); $this->assertSame($command, $this->event->getCustomCommand()); }
/** * Forwards events for command aliases to handlers for their corresponding * commands. * * @param string $alias * @param string $command * @param string $eventName * @param array $customParameters * @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue */ public function forwardEvent($alias, $command, $eventName, $customParameters, Event $event, Queue $queue) { if (is_array($customParameters)) { $eventCustomParams = $event->getCustomParams(); if (is_array($eventCustomParams)) { $event->setCustomParams(array_merge($customParameters, $eventCustomParams)); } else { $event->setCustomParams($customParameters); } } $logger = $this->getLogger(); $emitter = $this->getEventEmitter(); $listeners = $emitter->listeners($eventName); if (!$listeners) { $logger->warning('Alias references unknown command', array('alias' => $alias, 'command' => $command)); return; } $logger->debug('Forwarding event', array('event_name' => $eventName, 'alias' => $alias, 'command' => $command)); // Set the event customCommand to match the command being aliased $event->setCustomCommand($command); $emitter->emit($eventName, array($event, $queue)); }