Example #1
0
 /**
  * Command handler
  *
  * This functions returns void to prevent is from breaking the chain.
  *
  * @param   string  $name    The command name
  * @param   object  $context The command context
  * @return  void
  */
 public function execute($name, CommandContext $context)
 {
     $type = '';
     if ($context->getSubject()) {
         $identifier = clone $context->getSubject()->getIdentifier();
         if ($identifier->path) {
             $type = array_shift($identifier->path);
         } else {
             $type = $identifier->name;
         }
     }
     $parts = explode('.', $name);
     $name = 'on' . ucfirst(array_shift($parts)) . ucfirst($type) . StringInflector::implode($parts);
     if ($this->getConfig()->clone_context) {
         $event = clone $context;
     } else {
         $event = $context;
     }
     $event = new Event($event);
     $event->setTarget($context->getSubject());
     $this->getEventDispatcher()->dispatchEvent($name, $event);
 }