From 3352066ecec47b67ae2550a7cb9b75057976e80f Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Thu, 8 Mar 2012 09:58:19 -0800 Subject: [PATCH] Use Installer for Create Project Command. --- src/Composer/Command/CreateProjectCommand.php | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index d21fafb64..ea6c4cd42 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -12,16 +12,18 @@ namespace Composer\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\OutputInterface; -use Composer\IO\IOInterface; use Composer\Factory; +use Composer\Installer; +use Composer\Installer\ProjectInstaller; +use Composer\IO\IOInterface; use Composer\Repository\ComposerRepository; use Composer\Repository\FilesystemRepository; -use Composer\Installer\ProjectInstaller; +use Composer\Script\EventDispatcher; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Install a package as new project into new directory. @@ -76,15 +78,6 @@ EOT ); } - protected function getInstallCommand($input, $output) - { - $app = $this->getApplication(); - return function() use ($app, $input, $output) { - $newInput = new ArrayInput(array('command' => 'install')); - $app->doRUn($newInput, $output); - }; - } - public function installProject(IOInterface $io, $installCommand, $packageName, $directory = null, $version = null, $preferSource = false, $repositoryUrl = null) { $dm = $this->createDownloadManager($io); @@ -126,7 +119,12 @@ EOT $io->write('Created project into directory ' . $directory . '', true); chdir($directory); - $installCommand(); + + $composer = Factory::create($io); + $eventDispatcher = new EventDispatcher($composer, $io); + $installer = Installer::create($io, $composer, $eventDispatcher); + + $installer->run($preferSource); } protected function createDownloadManager(IOInterface $io)