Moved global param controller to routes
This commit is contained in:
parent
40b16f586b
commit
a3b02adb7f
3 changed files with 35 additions and 31 deletions
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
namespace Szurubooru\Controllers;
|
|
||||||
use Szurubooru\Dao\GlobalParamDao;
|
|
||||||
use Szurubooru\Router;
|
|
||||||
|
|
||||||
final class GlobalParamController extends AbstractController
|
|
||||||
{
|
|
||||||
private $globalParamDao;
|
|
||||||
|
|
||||||
public function __construct(GlobalParamDao $globalParamDao)
|
|
||||||
{
|
|
||||||
$this->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;
|
|
||||||
}
|
|
||||||
}
|
|
34
src/Routes/GetGlobals.php
Normal file
34
src/Routes/GetGlobals.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
namespace Szurubooru\Routes;
|
||||||
|
use Szurubooru\Dao\GlobalParamDao;
|
||||||
|
|
||||||
|
class GetGlobals extends AbstractRoute
|
||||||
|
{
|
||||||
|
private $globalParamDao;
|
||||||
|
|
||||||
|
public function __construct(GlobalParamDao $globalParamDao)
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,7 +62,6 @@ return [
|
||||||
$container->get(\Szurubooru\Controllers\PostController::class),
|
$container->get(\Szurubooru\Controllers\PostController::class),
|
||||||
$container->get(\Szurubooru\Controllers\PostContentController::class),
|
$container->get(\Szurubooru\Controllers\PostContentController::class),
|
||||||
$container->get(\Szurubooru\Controllers\PostNotesController::class),
|
$container->get(\Szurubooru\Controllers\PostNotesController::class),
|
||||||
$container->get(\Szurubooru\Controllers\GlobalParamController::class),
|
|
||||||
$container->get(\Szurubooru\Controllers\HistoryController::class),
|
$container->get(\Szurubooru\Controllers\HistoryController::class),
|
||||||
$container->get(\Szurubooru\Controllers\ScoreController::class),
|
$container->get(\Szurubooru\Controllers\ScoreController::class),
|
||||||
$container->get(\Szurubooru\Controllers\TagController::class),
|
$container->get(\Szurubooru\Controllers\TagController::class),
|
||||||
|
@ -72,6 +71,7 @@ return [
|
||||||
'routes' => DI\factory(function (DI\container $container) {
|
'routes' => DI\factory(function (DI\container $container) {
|
||||||
return [
|
return [
|
||||||
$container->get(\Szurubooru\Routes\Login::class),
|
$container->get(\Szurubooru\Routes\Login::class),
|
||||||
|
$container->get(\Szurubooru\Routes\GetGlobals::class),
|
||||||
$container->get(\Szurubooru\Routes\Comments\AddComment::class),
|
$container->get(\Szurubooru\Routes\Comments\AddComment::class),
|
||||||
$container->get(\Szurubooru\Routes\Comments\EditComment::class),
|
$container->get(\Szurubooru\Routes\Comments\EditComment::class),
|
||||||
$container->get(\Szurubooru\Routes\Comments\DeleteComment::class),
|
$container->get(\Szurubooru\Routes\Comments\DeleteComment::class),
|
||||||
|
|
Loading…
Reference in a new issue