浏览代码

Make Event devMode argument optional (false by default).

Ronny López 12 年之前
父节点
当前提交
f627c3c603

+ 1 - 1
src/Composer/Autoload/AutoloadGenerator.php

@@ -186,7 +186,7 @@ EOF;
         file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix));
         copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
 
-        $this->eventDispatcher->dispatch(ScriptEvents::POST_AUTOLOAD_DUMP, false);
+        $this->eventDispatcher->dispatch(ScriptEvents::POST_AUTOLOAD_DUMP);
     }
 
     public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)

+ 1 - 1
src/Composer/Script/Event.php

@@ -50,7 +50,7 @@ class Event
      * @param IOInterface $io       The IOInterface object
      * @param boolean     $devMode  Whether or not we are in dev mode
      */
-    public function __construct($name, Composer $composer, IOInterface $io, $devMode)
+    public function __construct($name, Composer $composer, IOInterface $io, $devMode = false)
     {
         $this->name = $name;
         $this->composer = $composer;

+ 7 - 3
src/Composer/Script/EventDispatcher.php

@@ -55,11 +55,15 @@ class EventDispatcher
      * Dispatch a script event.
      *
      * @param string  $eventName The constant in ScriptEvents
-     * @param boolean $devMode   Whether or not we are in dev mode
+     * @param Event $event
      */
-    public function dispatch($eventName, $devMode)
+    public function dispatch($eventName, Event $event = null)
     {
-        $this->doDispatch(new Event($eventName, $this->composer, $this->io, $devMode));
+        if (null == $event) {
+            $event = new Event($eventName, $this->composer, $this->io);
+        }
+
+        $this->doDispatch($event);
     }
 
     /**