From 8b52e2fe8b8920b2fbbe4e0bb59bde3ba765fe3a Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 17 Dec 2016 20:05:06 +0100 Subject: [PATCH] pass project to cli --- ipf/cli.php | 14 +++++++++++--- ipf/project.php | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ipf/cli.php b/ipf/cli.php index 5626b05..58df021 100644 --- a/ipf/cli.php +++ b/ipf/cli.php @@ -10,9 +10,18 @@ class IPF_Cli { + /** @var IPF_Project */ + private $project; + + /** @var array */ protected $commands; - public function __construct() + public function __construct(IPF_Project $project) + { + $this->project = $project; + } + + public function findCommands() { $this->commands = array( 'IPF' => array( @@ -30,7 +39,7 @@ class IPF_Cli ), ); - foreach (IPF_Project::getInstance()->appList() as $app) { + foreach ($this->project->appList() as $app) { $commands = $app->commands(); if (count($commands)) $this->commands[$app->getName()] = $commands; @@ -108,4 +117,3 @@ class IPF_Cli } } } - diff --git a/ipf/project.php b/ipf/project.php index 6ca989e..e09b84b 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -64,7 +64,8 @@ final class IPF_Project } if (php_sapi_name() === 'cli') { - $cli = new IPF_Cli; + $cli = new IPF_Cli($this); + $cli->findCommands(); $cli->run(); } else { $this->request = new IPF_HTTP_Request; -- 2.49.0