1
0
Fork 0

Merge pull request #1871 from taylorotwell/master

Added "pre-autoload-dump" event.
pull/1872/head
Jordi Boggiano 2013-05-06 09:23:45 -07:00
commit 70c86ca18e
5 changed files with 25 additions and 3 deletions

View File

@ -30,6 +30,8 @@ Composer fires the following named events during its execution process:
- **post-package-update**: occurs after a package is updated. - **post-package-update**: occurs after a package is updated.
- **pre-package-uninstall**: occurs before a package has been uninstalled. - **pre-package-uninstall**: occurs before a package has been uninstalled.
- **post-package-uninstall**: occurs after 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 - **post-autoload-dump**: occurs after the autoloader is dumped, either
during `install`/`update`, or via the `dump-autoload` command. during `install`/`update`, or via the `dump-autoload` command.

View File

@ -283,9 +283,13 @@
"type": ["array", "string"], "type": ["array", "string"],
"description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands." "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": { "post-autoload-dump": {
"type": ["array", "string"], "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."
} }
} }
}, },

View File

@ -39,6 +39,8 @@ class AutoloadGenerator
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '') 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 = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir')); $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$basePath = $filesystem->normalizePath(getcwd()); $basePath = $filesystem->normalizePath(getcwd());

View File

@ -110,6 +110,15 @@ class ScriptEvents
*/ */
const POST_PACKAGE_UNINSTALL = 'post-package-uninstall'; 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 POST_AUTOLOAD_DUMP event occurs after the autoload file has been generated.
* *

View File

@ -619,10 +619,15 @@ EOF;
$this->assertFalse(file_exists($this->vendorDir."/composer/include_paths.php")); $this->assertFalse(file_exists($this->vendorDir."/composer/include_paths.php"));
} }
public function testEventIsDispatchedAfterAutoloadDump() public function testPreAndPostEventsAreDispatchedDuringAutoloadDump()
{ {
$this->eventDispatcher $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') ->method('dispatch')
->with(ScriptEvents::POST_AUTOLOAD_DUMP, false); ->with(ScriptEvents::POST_AUTOLOAD_DUMP, false);