From 6844d7b572d05f22a5b956b16363e7da1643d97c Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 27 Mar 2012 00:59:08 +0200 Subject: [PATCH] Removed scripts documentation duplication, refactor to the dedicated article page --- doc/04-schema.md | 54 +---------------------------------------- doc/articles/scripts.md | 17 ++++++++++--- 2 files changed, 14 insertions(+), 57 deletions(-) diff --git a/doc/04-schema.md b/doc/04-schema.md index e0a5f77d5..862f70c4d 100644 --- a/doc/04-schema.md +++ b/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 diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index ade1551cc..3da238f31 100644 --- a/doc/articles/scripts.md +++ b/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 : getComposer(); // do stuff } - public static function postPackageInstall($event) + public static function postPackageInstall(Event $event) { $installedPackage = $event->getOperation()->getPackage(); // do stuff