diff --git a/flight/commands/ControllerCommand.php b/flight/commands/ControllerCommand.php index 9706d97..cfea2ae 100644 --- a/flight/commands/ControllerCommand.php +++ b/flight/commands/ControllerCommand.php @@ -29,7 +29,7 @@ public function __construct(array $config) public function execute(string $controller) { $io = $this->app()->io(); - if (isset($this->config['app_root']) === false) { + if (isset($this->config['runway']['app_root']) === false) { $io->error('app_root not set in .runway-config.json', true); return; } @@ -38,7 +38,7 @@ public function execute(string $controller) $controller .= 'Controller'; } - $controllerPath = getcwd() . DIRECTORY_SEPARATOR . $this->config['app_root'] . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php'; + $controllerPath = getcwd() . DIRECTORY_SEPARATOR . $this->config['runway']['app_root'] . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php'; if (file_exists($controllerPath) === true) { $io->error($controller . ' already exists.', true); return; @@ -86,6 +86,6 @@ public function execute(string $controller) protected function persistClass(string $controllerName, PhpFile $file) { $printer = new \Nette\PhpGenerator\PsrPrinter(); - file_put_contents(getcwd() . DIRECTORY_SEPARATOR . $this->config['app_root'] . 'controllers' . DIRECTORY_SEPARATOR . $controllerName . '.php', $printer->printFile($file)); + file_put_contents(getcwd() . DIRECTORY_SEPARATOR . $this->config['runway']['app_root'] . 'controllers' . DIRECTORY_SEPARATOR . $controllerName . '.php', $printer->printFile($file)); } } diff --git a/flight/commands/RouteCommand.php b/flight/commands/RouteCommand.php index bbcf52e..1b2691d 100644 --- a/flight/commands/RouteCommand.php +++ b/flight/commands/RouteCommand.php @@ -41,7 +41,8 @@ public function execute() { $io = $this->app()->io(); - if (isset($this->config['index_root']) === false) { + + if (isset($this->config['runway']['index_root']) === false) { $io->error('index_root not set in .runway-config.json', true); return; } @@ -50,7 +51,7 @@ public function execute() $cwd = getcwd(); - $index_root = $cwd . '/' . $this->config['index_root']; + $index_root = $cwd . '/' . $this->config['runway']['index_root']; // This makes it so the framework doesn't actually execute Flight::map('start', function () { diff --git a/tests/commands/ControllerCommandTest.php b/tests/commands/ControllerCommandTest.php index 510aaa2..f4903a2 100644 --- a/tests/commands/ControllerCommandTest.php +++ b/tests/commands/ControllerCommandTest.php @@ -67,7 +67,7 @@ public function testControllerAlreadyExists(): void $app = $this->newApp('test', '0.0.1'); mkdir(__DIR__ . '/controllers/'); file_put_contents(__DIR__ . '/controllers/TestController.php', 'add(new ControllerCommand(['app_root' => 'tests/commands/'])); + $app->add(new ControllerCommand(['runway' => ['app_root' => 'tests/commands/']])); $app->handle(['runway', 'make:controller', 'Test']); $this->assertStringContainsString('TestController already exists.', file_get_contents(static::$ou)); @@ -76,7 +76,7 @@ public function testControllerAlreadyExists(): void public function testCreateController(): void { $app = $this->newApp('test', '0.0.1'); - $app->add(new ControllerCommand(['app_root' => 'tests/commands/'])); + $app->add(new ControllerCommand(['runway' => ['app_root' => 'tests/commands/']])); $app->handle(['runway', 'make:controller', 'Test']); $this->assertFileExists(__DIR__ . '/controllers/TestController.php'); diff --git a/tests/commands/RouteCommandTest.php b/tests/commands/RouteCommandTest.php index 0d2aee7..993599c 100644 --- a/tests/commands/RouteCommandTest.php +++ b/tests/commands/RouteCommandTest.php @@ -101,7 +101,7 @@ public function testGetRoutes(): void { $app = @$this->newApp('test', '0.0.1'); $this->createIndexFile(); - $app->add(new RouteCommand(['index_root' => 'tests/commands/index.php'])); + $app->add(new RouteCommand(['runway' => ['index_root' => 'tests/commands/index.php']])); @$app->handle(['runway', 'routes']); $this->assertStringContainsString('Routes', file_get_contents(static::$ou)); @@ -127,7 +127,7 @@ public function testGetPostRoute(): void { $app = @$this->newApp('test', '0.0.1'); $this->createIndexFile(); - $app->add(new RouteCommand(['index_root' => 'tests/commands/index.php'])); + $app->add(new RouteCommand(['runway' => ['index_root' => 'tests/commands/index.php']])); @$app->handle(['runway', 'routes', '--post']); $this->assertStringContainsString('Routes', file_get_contents(static::$ou));