Permalink
Browse files

Added "pre-autoload-dump" event.

This event is fired before the autoload file is generated, for either
an install or update command.
  • Loading branch information...
1 parent 8a06e46 commit 60cd875cc2623c95a8fbc06e0e0f874c7657a483 @taylorotwell taylorotwell committed May 6, 2013
View
@@ -30,6 +30,8 @@ Composer fires the following named events during its execution process:
- **post-package-update**: occurs after a package is updated.
- **pre-package-uninstall**: occurs before a package has been uninstalled.
- **post-package-uninstall**: occurs after a package has been uninstalled.
+- **pre-autoload-dump**: occurs before the autoloader is dumped, either
+ during `install`/`update`, or via the `dump-autoload` command.
- **post-autoload-dump**: occurs after the autoloader is dumped, either
during `install`/`update`, or via the `dump-autoload` command.
View
@@ -283,9 +283,13 @@
"type": ["array", "string"],
"description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
},
+ "pre-autoload-dump": {
+ "type": ["array", "string"],
+ "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
+ },
"post-autoload-dump": {
"type": ["array", "string"],
- "description": "Occurs after a the autoloader is dumped, contains one or more Class::method callables or shell commands."
+ "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
}
}
},
@@ -39,6 +39,8 @@ public function __construct(EventDispatcher $eventDispatcher)
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
{
+ $this->eventDispatcher->dispatch(ScriptEvents::PRE_AUTOLOAD_DUMP);
+
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$basePath = $filesystem->normalizePath(getcwd());
@@ -111,6 +111,15 @@ class ScriptEvents
const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
/**
+ * The PRE_AUTOLOAD_DUMP event occurs before the autoload file is generated.
+ *
+ * The event listener method receives a Composer\Script\Event instance.
+ *
+ * @var string
+ */
+ const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
+
+ /**
* The POST_AUTOLOAD_DUMP event occurs after the autoload file has been generated.
*
* The event listener method receives a Composer\Script\Event instance.
@@ -619,10 +619,15 @@ public function testIncludePathFileWithoutPathsIsSkipped()
$this->assertFalse(file_exists($this->vendorDir."/composer/include_paths.php"));
}
- public function testEventIsDispatchedAfterAutoloadDump()
+ public function testPreAndPostEventsAreDispatchedDuringAutoloadDump()
{
$this->eventDispatcher
- ->expects($this->once())
+ ->expects($this->at(0))
+ ->method('dispatch')
+ ->with(ScriptEvents::PRE_AUTOLOAD_DUMP, false);
+
+ $this->eventDispatcher
+ ->expects($this->at(1))
->method('dispatch')
->with(ScriptEvents::POST_AUTOLOAD_DUMP, false);

0 comments on commit 60cd875

Please sign in to comment.