/**
  * @param AbstractEvent $event
  *
  * @throws BadMethodCallException
  */
 private function executeEvent(AbstractEvent $event)
 {
     $eventName = ClassUtils::getShortName($event);
     $method = sprintf('apply%s', (string) $eventName);
     if (!method_exists($this, $method)) {
         throw new BadMethodCallException(sprintf('You must define the %s::%s(%s $event) method in order to apply event named "%s".', get_class($this), $method, get_class($event), $eventName));
     }
     $this->{$method}($event);
 }
 /**
  * @param AbstractEvent $event
  * @param bool          $asynchronous
  *
  * @return AbstractEvent
  */
 public function publish(AbstractEvent $event, $asynchronous = false)
 {
     $eventName = ClassUtils::getCanonicalName($event);
     $this->doPublish($this->getListeners($event, $asynchronous), $eventName, $event);
     return $event;
 }
Esempio n. 3
0
 /**
  * @dataProvider getShortNameProvider
  *
  * @param mixed  $class
  * @param string $expectedShortName
  */
 public function testGetShortName($class, $expectedShortName)
 {
     $this->assertEquals($expectedShortName, ClassUtils::getShortName($class));
 }