From 24b9be7d5cc72b917f8f5ca85143482997b11ca9 Mon Sep 17 00:00:00 2001 From: Bluebat Date: Wed, 29 Aug 2018 13:00:09 +0200 Subject: [PATCH] https://github.com/igniphp/stilus/issues/35 --- src/api/Hello/SayHello.php | 4 ---- src/api/Stilus.php | 16 +++++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/api/Hello/SayHello.php b/src/api/Hello/SayHello.php index 21fe4e4..04efd99 100644 --- a/src/api/Hello/SayHello.php +++ b/src/api/Hello/SayHello.php @@ -16,13 +16,9 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface return Response::fromText("Hello {$request->getAttribute('name')}!"); } - /* - * Initial commit - */ public static function getRoute(): Route { return Route::get('/hello/{name}'); } - //pull test2 } diff --git a/src/api/Stilus.php b/src/api/Stilus.php index 2f48a85..a0c55fc 100644 --- a/src/api/Stilus.php +++ b/src/api/Stilus.php @@ -83,8 +83,8 @@ private function setupServer(array $config): Server $httpConfiguration->setLogFile(STILUS_DIR . DIRECTORY_SEPARATOR . $config['log_file']); } - define('STILUS_SERVER_ENABLED', true); - define('STILUS_SERVER_START', time()); + \define('STILUS_SERVER_ENABLED', true); + \define('STILUS_SERVER_START', time()); return new Server($httpConfiguration); } @@ -101,15 +101,17 @@ public function main(): void } $server = null; - if (isset($config['api']) && - isset($config['api']['http_server']) && - isset($config['api']['http_server']['enable']) && - $config['api']['http_server']['enable'] - ) { + if ($this->isServerEnable($config)) + { $server = $this->setupServer($config['api']['http_server']); } $application->run($server); } + private function isServerEnable(array $config): bool + { + return isset($config['api']['http_server']['enable']) && $config['api']['http_server']['enable']; + } + // Run application in contained scope })->main();