Exemplo n.º 1
0
 /**
  * @param string $eventName
  * @param Event|null $event
  * @return Event|null
  */
 public function dispatch($eventName, Event $event = null)
 {
     parent::dispatch($eventName, $event);
     if ($event instanceof FormAwareInterface) {
         parent::dispatch($eventName . '.' . $event->getForm()->getName(), $event);
     }
     return $event;
 }
Exemplo n.º 2
0
 /**
  * @param string $eventName
  * @param GridEventInterface|GridConfigurationEventInterface|Event $event
  *
  * @return Event
  * @throws InvalidArgumentException
  */
 public function dispatch($eventName, Event $event = null)
 {
     /** @var DatagridConfiguration $config */
     if ($event instanceof GridEventInterface) {
         $config = $event->getDatagrid()->getConfig();
     } elseif ($event instanceof GridConfigurationEventInterface) {
         $config = $event->getConfig();
     } else {
         throw new InvalidArgumentException('Unexpected event type. Expected instance of GridEventInterface or GridConfigurationEventInterface');
     }
     // get all parents
     $invokedGrids = $config->offsetGetOr(SystemAwareResolver::KEY_EXTENDED_FROM, []);
     $invokedGrids[] = $config->getName();
     parent::dispatch($eventName, $event);
     /*
      * Dispatch named events in reverse order from parent to child
      * e.g. parent1 -> parent2 -> target grid
      */
     foreach ($invokedGrids as $grid) {
         parent::dispatch($eventName . '.' . $grid, $event);
     }
     return $event;
 }
 /**
  * @expectedException \BadMethodCallException
  */
 public function testRemoveSubscriberDisallowed()
 {
     $subscriber = $this->getMock('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface');
     $this->dispatcher->removeSubscriber($subscriber);
 }