From: Andrey Kutejko Date: Sat, 17 Dec 2016 19:05:06 +0000 (+0100) Subject: pass project to cli X-Git-Tag: 0.6~37 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=8b52e2fe8b8920b2fbbe4e0bb59bde3ba765fe3a;p=ipf.git pass project to cli --- 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;