/**
  * Generates and stores the Command object depending on the triggered event.
  * 
  * @param Event $event
  */
 public function createCommand($event)
 {
     if (!empty($this->commands[$event->name])) {
         if (is_callable($this->condition) && call_user_func($this->condition, $this->owner) === false) {
             return;
         }
         $class = $this->commands[$event->name];
         $command = new $class();
         if ($command instanceof CommandInterface === false) {
             throw new InvalidParamException('Class name [' . get_class($class) . '] provided in "commands" param MUST implement the jlorente\\command\\base\\CommandInterface interface');
         }
         $command->setReceiver($this->owner);
         CommandMapper::map($command);
     }
 }
 /**
  * Processes a mapper deleting it from the list and executing the command 
  * stored in it.
  * 
  * @param CommandMapper $mapper
  */
 protected function processMapper(CommandMapper $mapper)
 {
     $command = $mapper->getCommand();
     try {
         $mapper->delete();
         $command->execute();
     } catch (Exception $ex) {
         $this->erroneousMappers->push($mapper);
         Yii::getLogger()->log('An error ocurred while processing command [' . get_class($command) . '].' . PHP_EOL . 'Exception: [' . $ex->getTraceAsString() . ']', Logger::LEVEL_ERROR, 'command');
     }
 }