From 0dcad313048251faa8706fa3faab20addc835e0a Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 16 Mar 2019 18:45:24 +0100 Subject: [PATCH] remove global router --- ipf/cli.php | 2 +- ipf/command/routes.php | 11 +++++++++-- ipf/project.php | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ipf/cli.php b/ipf/cli.php index bf69e69..bc1a9da 100644 --- a/ipf/cli.php +++ b/ipf/cli.php @@ -19,7 +19,7 @@ class IPF_Cli_Provider implements ServiceProviderInterface { return array( new IPF_Command_Shell, new IPF_Command_DebugServer, - new IPF_Command_Routes, + new IPF_Command_Routes($c['router']), new IPF_Command_DB, new IPF_Command_DBDump, new IPF_Command_DBRestore, diff --git a/ipf/command/routes.php b/ipf/command/routes.php index ad57ee4..7975328 100644 --- a/ipf/command/routes.php +++ b/ipf/command/routes.php @@ -5,10 +5,17 @@ class IPF_Command_Routes public $command = 'routes'; public $description = 'Displays all routes'; + /** @var IPF_Router */ + private $router; + + function __construct(IPF_Router $router) + { + $this->router = $router; + } + public function run($args=null) { - $rows = IPF_Project::getInstance()->router->describe(); + $rows = $this->router->describe(); IPF_Shell::displayTwoColumns($rows); } } - diff --git a/ipf/project.php b/ipf/project.php index d4b9b6f..bf6ac37 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -10,7 +10,6 @@ final class IPF_Project /** @var Container */ private $container = null; private $apps = array(); - public $router = null; public $request = null; static private $instance = NULL; @@ -45,7 +44,6 @@ final class IPF_Project $settings->get('app_base') ); }; - $this->router = $this->container['router']; } private function __clone() -- 2.49.0