Пример #1
0
 /**
  * @param Event $event
  */
 public function dispatch(Event $event)
 {
     if (!isset($this->listeners[$event->getName()])) {
         return;
     }
     foreach ($this->listeners[$event->getName()] as $listener) {
         call_user_func_array($listener, array($event));
     }
 }
Пример #2
0
 /**
  * Finds all listeners defined as scripts in the package
  *
  * @param  Event $event Event object
  * @return array Listeners
  */
 protected function getScriptListeners(Event $event)
 {
     $package = $this->composer->getPackage();
     $scripts = $package->getScripts();
     if (empty($scripts[$event->getName()])) {
         return array();
     }
     if ($this->loader) {
         $this->loader->unregister();
     }
     $generator = $this->composer->getAutoloadGenerator();
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
     $map = $generator->parseAutoloads($packageMap, $package);
     $this->loader = $generator->createLoader($map);
     $this->loader->register();
     return $scripts[$event->getName()];
 }
Пример #3
0
 /**
  * Push an event to the stack of active event
  *
  * @param  Event             $event
  * @throws \RuntimeException
  * @return number
  */
 protected function pushEvent(Event $event)
 {
     $eventName = $event->getName();
     if (in_array($eventName, $this->eventStack)) {
         throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
     }
     return array_push($this->eventStack, $eventName);
 }