From a3b02adb7f8187e45165c1aa453c175ad5f540d4 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 21 Nov 2014 10:26:41 +0100 Subject: [PATCH] Moved global param controller to routes --- src/Controllers/GlobalParamController.php | 30 -------------------- src/Routes/GetGlobals.php | 34 +++++++++++++++++++++++ src/di.php | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-) delete mode 100644 src/Controllers/GlobalParamController.php create mode 100644 src/Routes/GetGlobals.php diff --git a/src/Controllers/GlobalParamController.php b/src/Controllers/GlobalParamController.php deleted file mode 100644 index 9b644fbb..00000000 --- a/src/Controllers/GlobalParamController.php +++ /dev/null @@ -1,30 +0,0 @@ -globalParamDao = $globalParamDao; - } - - public function registerRoutes(Router $router) - { - $router->get('/api/globals', [$this, 'getGlobals']); - } - - public function getGlobals() - { - $globals = $this->globalParamDao->findAll(); - $return = []; - foreach ($globals as $global) - { - $return[$global->getKey()] = $global->getValue(); - } - return $return; - } -} diff --git a/src/Routes/GetGlobals.php b/src/Routes/GetGlobals.php new file mode 100644 index 00000000..a721833c --- /dev/null +++ b/src/Routes/GetGlobals.php @@ -0,0 +1,34 @@ +globalParamDao = $globalParamDao; + } + + public function getMethods() + { + return ['GET']; + } + + public function getUrl() + { + return '/api/globals'; + } + + public function work() + { + $globals = $this->globalParamDao->findAll(); + $result = []; + foreach ($globals as $global) + { + $result[$global->getKey()] = $global->getValue(); + } + return $result; + } +} diff --git a/src/di.php b/src/di.php index 05a26113..d846c0f4 100644 --- a/src/di.php +++ b/src/di.php @@ -62,7 +62,6 @@ return [ $container->get(\Szurubooru\Controllers\PostController::class), $container->get(\Szurubooru\Controllers\PostContentController::class), $container->get(\Szurubooru\Controllers\PostNotesController::class), - $container->get(\Szurubooru\Controllers\GlobalParamController::class), $container->get(\Szurubooru\Controllers\HistoryController::class), $container->get(\Szurubooru\Controllers\ScoreController::class), $container->get(\Szurubooru\Controllers\TagController::class), @@ -72,6 +71,7 @@ return [ 'routes' => DI\factory(function (DI\container $container) { return [ $container->get(\Szurubooru\Routes\Login::class), + $container->get(\Szurubooru\Routes\GetGlobals::class), $container->get(\Szurubooru\Routes\Comments\AddComment::class), $container->get(\Szurubooru\Routes\Comments\EditComment::class), $container->get(\Szurubooru\Routes\Comments\DeleteComment::class),