From 3245c751879c4cc983aa3f302e168c404f3ae369 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 21 Nov 2014 21:49:26 +0100 Subject: [PATCH] Removed controller layer --- src/ControllerRepository.php | 17 ----------------- src/Controllers/AbstractController.php | 8 -------- src/Dispatcher.php | 7 +------ src/di.php | 6 ------ tests/ControllerRepositoryTest.php | 13 ------------- tests/DispatcherTest.php | 9 +-------- 6 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 src/ControllerRepository.php delete mode 100644 src/Controllers/AbstractController.php delete mode 100644 tests/ControllerRepositoryTest.php diff --git a/src/ControllerRepository.php b/src/ControllerRepository.php deleted file mode 100644 index 2fc2e26b..00000000 --- a/src/ControllerRepository.php +++ /dev/null @@ -1,17 +0,0 @@ -controllers = $controllers; - } - - public function getControllers() - { - return $this->controllers; - } -} diff --git a/src/Controllers/AbstractController.php b/src/Controllers/AbstractController.php deleted file mode 100644 index feed4ab0..00000000 --- a/src/Controllers/AbstractController.php +++ /dev/null @@ -1,8 +0,0 @@ -router = $router; $this->config = $config; @@ -37,9 +35,6 @@ final class Dispatcher //if script fails prematurely, mark it as fail from advance $this->httpHelper->setResponseCode(500); - foreach ($controllerRepository->getControllers() as $controller) - $controller->registerRoutes($router); - $routeRepository->injectRoutes($router); } diff --git a/src/di.php b/src/di.php index e8073a69..73ef2304 100644 --- a/src/di.php +++ b/src/di.php @@ -12,7 +12,6 @@ return [ \Szurubooru\Config::class => DI\object()->constructor($dataDirectory, $publicDataDirectory), \Szurubooru\RouteRepository::class => DI\object()->constructor(DI\link('routes')), - \Szurubooru\ControllerRepository::class => DI\object()->constructor(DI\link('controllers')), \Szurubooru\Upgrades\UpgradeRepository::class => DI\object()->constructor(DI\link('upgrades')), 'upgrades' => DI\factory(function (DI\container $container) { @@ -55,11 +54,6 @@ return [ ]; }), - 'controllers' => DI\factory(function (DI\container $container) { - return [ - ]; - }), - 'routes' => DI\factory(function (DI\container $container) { return [ $container->get(\Szurubooru\Routes\Login::class), diff --git a/tests/ControllerRepositoryTest.php b/tests/ControllerRepositoryTest.php deleted file mode 100644 index e9ca7063..00000000 --- a/tests/ControllerRepositoryTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertNotEmpty($controllerRepository->getControllers()); - } -} diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php index 228a893c..63f0498c 100644 --- a/tests/DispatcherTest.php +++ b/tests/DispatcherTest.php @@ -1,6 +1,5 @@ httpHelperMock = $this->mock(HttpHelper::class); $this->authServiceMock = $this->mock(AuthService::class); $this->tokenServiceMock = $this->mock(TokenService::class); - $this->controllerRepositoryMock = $this->mock(ControllerRepository::class); $this->routeRepositoryMock = $this->mock(RouteRepository::class); $this->configMock->set('misc/dumpSqlIntoQueries', 0); } @@ -41,7 +38,6 @@ final class DispatcherTest extends AbstractDatabaseTestCase ->method('setResponseCode') ->withConsecutive([$this->equalTo(500)], [$this->equalTo(200)]); $this->routerMock->expects($this->once())->method('handle')->willReturn($expected); - $this->controllerRepositoryMock->method('getControllers')->willReturn([]); $this->routeRepositoryMock->expects($this->once())->method('injectRoutes'); $dispatcher = $this->getDispatcher(); @@ -58,7 +54,6 @@ final class DispatcherTest extends AbstractDatabaseTestCase $expected = ['bunny' => 5]; $this->routerMock->expects($this->once())->method('handle')->willReturn($classData); - $this->controllerRepositoryMock->method('getControllers')->willReturn([]); $this->routeRepositoryMock->expects($this->once())->method('injectRoutes'); $dispatcher = $this->getDispatcher(); @@ -72,7 +67,6 @@ final class DispatcherTest extends AbstractDatabaseTestCase { $this->httpHelperMock->expects($this->once())->method('getRequestHeader')->with($this->equalTo('X-Authorization-Token'))->willReturn('test'); $this->tokenServiceMock->expects($this->once())->method('getByName'); - $this->controllerRepositoryMock->method('getControllers')->willReturn([]); $this->routeRepositoryMock->expects($this->once())->method('injectRoutes'); $dispatcher = $this->getDispatcher(); @@ -88,7 +82,6 @@ final class DispatcherTest extends AbstractDatabaseTestCase $this->httpHelperMock, $this->authServiceMock, $this->tokenServiceMock, - $this->routeRepositoryMock, - $this->controllerRepositoryMock); + $this->routeRepositoryMock); } }