فهرست منبع

Merge pull request #502 from romainneutron/master

Removed scripts documentation duplication, refactor to the dedicated article page
Jordi Boggiano 13 سال پیش
والد
کامیت
a3185c75fe
2فایلهای تغییر یافته به همراه14 افزوده شده و 57 حذف شده
  1. 1 53
      doc/04-schema.md
  2. 13 4
      doc/articles/scripts.md

+ 1 - 53
doc/04-schema.md

@@ -335,59 +335,7 @@ Example:
 Composer allows you to hook into various parts of the installation process
 through the use of scripts.
 
-These events are supported:
-
-* **pre-install-cmd:** Occurs before the install command is executed, contains
-  one or more Class::method callables.
-* **post-install-cmd:** Occurs after the install command is executed, contains
-  one or more Class::method callables.
-* **pre-update-cmd:** Occurs before the update command is executed, contains
-  one or more Class::method callables.
-* **post-update-cmd:** Occurs after the update command is executed, contains
-  one or more Class::method callables.
-* **pre-package-install:** Occurs before a package is installed, contains one
-  or more Class::method callables.
-* **post-package-install:** Occurs after a package is installed, contains one
-  or more Class::method callables.
-* **pre-package-update:** Occurs before a package is updated, contains one or
-  more Class::method callables.
-* **post-package-update:** Occurs after a package is updated, contains one or
-  more Class::method callables.
-* **pre-package-uninstall:** Occurs before a package has been uninstalled,
-  contains one or more Class::method callables.
-* **post-package-uninstall:** Occurs after a package has been uninstalled,
-  contains one or more Class::method callables.
-
-For each of these events you can provide a static method on a class that will
-handle it.
-
-Example:
-
-    {
-        "scripts": {
-            "post-install-cmd": [
-                "Acme\\ScriptHandler::doSomething"
-            ]
-        }
-    }
-
-The event handler receives a `Composer\Script\Event` object as an argument,
-which gives you access to the `Composer\Composer` instance through the
-`getComposer` method.
-
-    namespace Acme;
-
-    use Composer\Script\Event;
-
-    class ScriptHandler
-    {
-        static public function doSomething(Event $event)
-        {
-            $composer = $event->getComposer();
-
-            // custom logic
-        }
-    }
+See [Scripts](articles/scripts.md) for events details and examples.
 
 ### extra
 

+ 13 - 4
doc/articles/scripts.md

@@ -40,24 +40,33 @@ Script definition example:
     {
         "scripts": {
             "post-update-cmd": "MyVendor\\MyClass::postUpdate",
-            "post-package-install": ["MyVendor\\MyClass::postPackageInstall"]
+            "post-package-install": [
+                "MyVendor\\MyClass::postPackageInstall"
+            ]
         }
     }
 
-Script listener example:
+The event handler receives a `Composer\Script\Event` object as an argument,
+which gives you access to the `Composer\Composer` instance through the
+`getComposer` method.
+
+Using the previous example, here's an event listener example :
 
     <?php
 
     namespace MyVendor;
 
+    use Composer\Script\Event;
+
     class MyClass
     {
-        public static function postUpdate($event)
+        public static function postUpdate(Event $event)
         {
+            $composer = $event->getComposer();
             // do stuff
         }
 
-        public static function postPackageInstall($event)
+        public static function postPackageInstall(Event $event)
         {
             $installedPackage = $event->getOperation()->getPackage();
             // do stuff