From ba855d9b56ae283603b73372719f2377ddf5774e Mon Sep 17 00:00:00 2001 From: Vassyli Date: Wed, 27 Jul 2016 08:57:10 +0200 Subject: [PATCH] Added root package to ComposerManager->getPackages() --- src/Bootstrap.php | 7 +++---- src/BootstrapInterface.php | 2 +- src/ComposerManager.php | 5 ++++- tests/FakeModule/Bootstrap.php | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Bootstrap.php b/src/Bootstrap.php index ca159d2..25c33cd 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -20,7 +20,6 @@ use Symfony\Component\Console\Application; use LotGD\Core\ { ComposerManager, BootstrapInterface, - Exceptions\ArgumentException, Exceptions\InvalidConfigurationException }; @@ -47,7 +46,7 @@ class Bootstrap public function getGame(): Game { $composer = $this->createComposerManager(); - $this->bootstrapClasses = $this->getBootstrapClasses($composer); + $this->bootstrapClasses = $this->initPackageBootstraps($composer); $config = $this->createConfiguration(); $logger = $this->createLogger($config, "lotgd"); @@ -114,7 +113,7 @@ class Bootstrap * @return array * @throws \Exception */ - protected function getBootstrapClasses(ComposerManager $composer): array + protected function initPackageBootstraps(ComposerManager $composer): array { $packages = $composer->getPackages(); $classes = []; @@ -223,7 +222,7 @@ class Bootstrap */ public function addDaenerysCommands(Application $application) { - foreach($this->bootstrapClasses as $bootstrap) + foreach ($this->bootstrapClasses as $bootstrap) { $bootstrap->addDaenerysCommand($this->game, $application); } diff --git a/src/BootstrapInterface.php b/src/BootstrapInterface.php index 813d97e..b10586f 100644 --- a/src/BootstrapInterface.php +++ b/src/BootstrapInterface.php @@ -9,5 +9,5 @@ interface BootstrapInterface { public function hasEntityPath(): bool; public function getEntityPath(): string; - public function addDaenerysCommand(Application $application); + public function addDaenerysCommand(Game $game, Application $application); } \ No newline at end of file diff --git a/src/ComposerManager.php b/src/ComposerManager.php index 9ed4203..01db5e9 100644 --- a/src/ComposerManager.php +++ b/src/ComposerManager.php @@ -71,7 +71,10 @@ class ComposerManager */ public function getPackages(): array { - return $this->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages(); + return array_merge( + [$this->getComposer()->getPackage()], + $this->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages() + ); } /** diff --git a/tests/FakeModule/Bootstrap.php b/tests/FakeModule/Bootstrap.php index ad33742..8654905 100644 --- a/tests/FakeModule/Bootstrap.php +++ b/tests/FakeModule/Bootstrap.php @@ -5,6 +5,7 @@ namespace LotGD\Core\Tests\FakeModule; use Symfony\Component\Console\Application; use LotGD\Core\BootstrapInterface; +use LotGD\Core\Game; class Bootstrap implements BootstrapInterface { @@ -18,7 +19,7 @@ class Bootstrap implements BootstrapInterface return __DIR__ . "/Models"; } - public function addDaenerysCommand(Application $application) + public function addDaenerysCommand(Game $game, Application $application) { }