1
0
Fork 0

CS fixes, made EventDispatcher optional in factory method

pull/387/merge
Jordi Boggiano 2012-03-10 01:16:37 +01:00
parent 2b2f7e1748
commit 5f2e42ec46
3 changed files with 25 additions and 29 deletions

View File

@ -18,7 +18,6 @@ use Composer\Installer\ProjectInstaller;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Repository\ComposerRepository; use Composer\Repository\ComposerRepository;
use Composer\Repository\FilesystemRepository; use Composer\Repository\FilesystemRepository;
use Composer\Script\EventDispatcher;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -119,8 +118,7 @@ EOT
chdir($directory); chdir($directory);
$composer = Factory::create($io); $composer = Factory::create($io);
$eventDispatcher = new EventDispatcher($composer, $io); $installer = Installer::create($io, $composer);
$installer = Installer::create($io, $composer, $eventDispatcher);
$installer->run($preferSource); $installer->run($preferSource);
} }

View File

@ -13,7 +13,6 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Installer; use Composer\Installer;
use Composer\Script\EventDispatcher;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -52,15 +51,14 @@ EOT
{ {
$composer = $this->getComposer(); $composer = $this->getComposer();
$io = $this->getApplication()->getIO(); $io = $this->getApplication()->getIO();
$eventDispatcher = new EventDispatcher($composer, $io); $install = Installer::create($io, $composer);
$install = Installer::create($io, $composer, $eventDispatcher);
return $install->run( return $install->run(
(Boolean)$input->getOption('prefer-source'), (Boolean) $input->getOption('prefer-source'),
(Boolean)$input->getOption('dry-run'), (Boolean) $input->getOption('dry-run'),
(Boolean)$input->getOption('verbose'), (Boolean) $input->getOption('verbose'),
(Boolean)$input->getOption('no-install-recommends'), (Boolean) $input->getOption('no-install-recommends'),
(Boolean)$input->getOption('install-suggests') (Boolean) $input->getOption('install-suggests')
); );
} }
} }

View File

@ -33,53 +33,51 @@ use Composer\Repository\RepositoryManager;
use Composer\Script\EventDispatcher; use Composer\Script\EventDispatcher;
use Composer\Script\ScriptEvents; use Composer\Script\ScriptEvents;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Beau Simensen <beau@dflydev.com>
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class Installer class Installer
{ {
/** /**
*
* @var IOInterface * @var IOInterface
*/ */
protected $io; protected $io;
/** /**
*
* @var PackageInterface * @var PackageInterface
*/ */
protected $package; protected $package;
/** /**
*
* @var DownloadManager * @var DownloadManager
*/ */
protected $downloadManager; protected $downloadManager;
/** /**
*
* @var RepositoryManager * @var RepositoryManager
*/ */
protected $repositoryManager; protected $repositoryManager;
/** /**
*
* @var Locker * @var Locker
*/ */
protected $locker; protected $locker;
/** /**
*
* @var InstallationManager * @var InstallationManager
*/ */
protected $installationManager; protected $installationManager;
/** /**
*
* @var EventDispatcher * @var EventDispatcher
*/ */
protected $eventDispatcher; protected $eventDispatcher;
/** /**
* Constructor * Constructor
* *
* @param IOInterface $io * @param IOInterface $io
* @param PackageInterface $package * @param PackageInterface $package
* @param DownloadManager $downloadManager * @param DownloadManager $downloadManager
@ -102,12 +100,12 @@ class Installer
/** /**
* Run installation (or update) * Run installation (or update)
* *
* @param bool $preferSource * @param Boolean $preferSource
* @param bool $dryRun * @param Boolean $dryRun
* @param bool $verbose * @param Boolean $verbose
* @param bool $noInstallRecommends * @param Boolean $noInstallRecommends
* @param bool $installSuggests * @param Boolean $installSuggests
* @param bool $update * @param Boolean $update
* @param RepositoryInterface $additionalInstalledRepository * @param RepositoryInterface $additionalInstalledRepository
*/ */
public function run($preferSource = false, $dryRun = false, $verbose = false, $noInstallRecommends = false, $installSuggests = false, $update = false, RepositoryInterface $additionalInstalledRepository = null) public function run($preferSource = false, $dryRun = false, $verbose = false, $noInstallRecommends = false, $installSuggests = false, $update = false, RepositoryInterface $additionalInstalledRepository = null)
@ -202,8 +200,8 @@ class Installer
} }
// prepare solver // prepare solver
$policy = new DefaultPolicy(); $policy = new DefaultPolicy();
$solver = new Solver($policy, $pool, $installedRepo); $solver = new Solver($policy, $pool, $installedRepo);
// solve dependencies // solve dependencies
$operations = $solver->solve($request); $operations = $solver->solve($request);
@ -316,14 +314,16 @@ class Installer
/** /**
* Create Installer * Create Installer
* *
* @param IOInterface $io * @param IOInterface $io
* @param Composer $composer * @param Composer $composer
* @param EventDispatcher $eventDispatcher * @param EventDispatcher $eventDispatcher
* @return Installer * @return Installer
*/ */
static public function create(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher) static public function create(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher = null)
{ {
$eventDispatcher = $eventDispatcher ?: new EventDispatcher($composer, $io);
return new static( return new static(
$io, $io,
$composer->getPackage(), $composer->getPackage(),