]> git.andy128k.dev Git - ipf.git/commitdiff
pass project to cli
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 17 Dec 2016 19:05:06 +0000 (20:05 +0100)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 17 Dec 2016 19:05:06 +0000 (20:05 +0100)
ipf/cli.php
ipf/project.php

index 5626b054329d600781339810cbd8cb531d957c6b..58df0215eabfb540b64a266f4d4f20f24519f78d 100644 (file)
 
 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
         }
     }
 }
-
index 6ca989ed8133c3844736f5b8a9583ed9c3b0d816..e09b84bd365e896faccdb4f24ec1d3c2edcb430f 100644 (file)
@@ -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;