Skip to content

Commit c48dc45

Browse files
committed
VSA + SRP Architecture refactoring
1 parent b2cf4a1 commit c48dc45

File tree

52 files changed

+240
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+240
-201
lines changed

config/container.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* Documentation: https://samuel-gfeller.ch/docs/Dependency-Injection.
66
*/
77

8-
use App\Infrastructure\Utility\Settings;
8+
use App\Core\Application\Middleware\PhpViewMiddleware;
9+
use App\Core\Infrastructure\Utility\Settings;
910
use Cake\Database\Connection;
1011
use Monolog\Formatter\LineFormatter;
1112
use Monolog\Handler\RotatingFileHandler;

config/middleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
use App\Application\Middleware\PhpViewMiddleware;
4-
use App\Application\Middleware\ValidationExceptionMiddleware;
3+
use App\Core\Application\Middleware\PhpViewMiddleware;
4+
use App\Core\Application\Middleware\ValidationExceptionMiddleware;
55
use Selective\BasePath\BasePathMiddleware;
66
use Slim\App;
77
use SlimErrorRenderer\Middleware\ExceptionHandlingMiddleware;

config/routes.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,41 @@
66

77
return function (App $app) {
88
// Home page
9-
$app->get('/', \App\Application\Action\Home\HomePageAction::class)->setName('home-page');
10-
$app->get('/home', \App\Application\Action\Home\RedirectToHomePageAction::class);
9+
$app->get('/', \App\Module\Home\HomePageAction::class)->setName('home-page');
10+
$app->get('/home', \App\Module\Home\RedirectToHomePageAction::class);
1111

1212
// User action routes
1313
$app->group('/users', function (RouteCollectorProxy $group) {
1414
// User list page
15-
$group->get('/list', \App\Application\Action\User\Page\UserListPageAction::class)
15+
$group->get('/list', \App\Module\User\List\Action\UserListPageAction::class)
1616
->setName('user-list-page');
1717
// Fetch user list for Ajax call
18-
$group->get('', \App\Application\Action\User\Ajax\UserFetchListAction::class)
18+
$group->get('', \App\Module\User\List\Action\UserFetchListAction::class)
1919
->setName('user-list');
2020
// Submit user creation form
21-
$group->post('', \App\Application\Action\User\Ajax\UserCreateAction::class)
21+
$group->post('', \App\Module\User\Create\Action\UserCreateAction::class)
2222
->setName('user-create-submit');
2323
// User read page
24-
$group->get('/{user_id:[0-9]+}', \App\Application\Action\User\Page\UserReadPageAction::class)
24+
$group->get('/{user_id:[0-9]+}', \App\Module\User\Read\Action\UserReadPageAction::class)
2525
->setName('user-read-page');
2626
// Submit user update form
27-
$group->put('/{user_id:[0-9]+}', \App\Application\Action\User\Ajax\UserUpdateAction::class)
27+
$group->put('/{user_id:[0-9]+}', \App\Module\User\Update\Action\UserUpdateAction::class)
2828
->setName('user-update-submit');
2929
// Submit delete user
30-
$group->delete('/{user_id:[0-9]+}', \App\Application\Action\User\Ajax\UserDeleteAction::class)
30+
$group->delete('/{user_id:[0-9]+}', \App\Module\User\Delete\Action\UserDeleteAction::class)
3131
->setName('user-delete-submit');
3232
});
3333

3434
// API routes
3535
$app->group('/api', function (RouteCollectorProxy $group) {
36-
$group->get('/users', \App\Application\Action\User\Api\ApiUserFetchListAction::class)->setName(
36+
$group->get('/users', \App\Module\User\List\Action\ApiUserFetchListAction::class)->setName(
3737
'api-fetch-users-list'
3838
);
3939
})// Cross-Origin Resource Sharing (CORS) middleware. Allow another domain to access '/api' routes.
4040
// If an error occurs, the CORS middleware will not be executed and the exception caught and a response
4141
// sent without the appropriate access control header. I don't know how to execute a certain middleware
4242
// added to a route group only before the error middleware which is added last in the middleware.php file.
43-
->add(\App\Application\Middleware\CorsMiddleware::class);
43+
->add(\App\Core\Application\Middleware\CorsMiddleware::class);
4444

4545
/**
4646
* Catch-all route to serve a 404 Not Found page if none of the routes match

phpunit.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
backupStaticProperties="false">
55
<coverage/>
66
<testsuites>
7-
<testsuite name="Integration">
8-
<directory suffix="Test.php">tests/Integration</directory>
9-
</testsuite>
10-
<testsuite name="Unit">
11-
<directory suffix="Test.php">tests/Unit</directory>
7+
<testsuite name="Tests">
8+
<directory suffix="Test.php">tests/TestCase</directory>
129
</testsuite>
1310
</testsuites>
1411
<php>

public/index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22
/**
3-
* Bootstrap the application
3+
* Bootstrap the application.
44
*
55
* Documentation: https://samuel-gfeller.ch/docs/Web-Server-config-and-Slim-Bootstrapping#slim-bootstrapping
66
*/
7-
87
$app = require __DIR__ . '/../config/bootstrap.php';
98

109
$app->run();

src/Application/Middleware/CorsMiddleware.php renamed to src/Core/Application/Middleware/CorsMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace App\Application\Middleware;
3+
namespace App\Core\Application\Middleware;
44

5-
use App\Infrastructure\Utility\Settings;
5+
use App\Core\Infrastructure\Utility\Settings;
66
use Psr\Http\Message\ResponseFactoryInterface;
77
use Psr\Http\Message\ResponseInterface;
88
use Psr\Http\Message\ServerRequestInterface;

src/Application/Middleware/PhpViewMiddleware.php renamed to src/Core/Application/Middleware/PhpViewMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace App\Application\Middleware;
3+
namespace App\Core\Application\Middleware;
44

5-
use App\Infrastructure\Utility\JsImportCacheBuster;
6-
use App\Infrastructure\Utility\Settings;
5+
use App\Core\Infrastructure\Utility\JsImportCacheBuster;
6+
use App\Core\Infrastructure\Utility\Settings;
77
use Psr\Http\Message\ResponseInterface;
88
use Psr\Http\Message\ServerRequestInterface;
99
use Psr\Http\Server\MiddlewareInterface;

src/Application/Middleware/ValidationExceptionMiddleware.php renamed to src/Core/Application/Middleware/ValidationExceptionMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace App\Application\Middleware;
3+
namespace App\Core\Application\Middleware;
44

5-
use App\Application\Responder\JsonResponder;
6-
use App\Domain\Exception\ValidationException;
5+
use App\Core\Application\Responder\JsonResponder;
6+
use App\Core\Domain\Exception\ValidationException;
77
use Psr\Http\Message\ResponseFactoryInterface;
88
use Psr\Http\Message\ResponseInterface;
99
use Psr\Http\Message\ServerRequestInterface;

src/Application/Responder/JsonResponder.php renamed to src/Core/Application/Responder/JsonResponder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Application\Responder;
3+
namespace App\Core\Application\Responder;
44

55
use Psr\Http\Message\ResponseInterface;
66

src/Application/Responder/RedirectHandler.php renamed to src/Core/Application/Responder/RedirectHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Application\Responder;
3+
namespace App\Core\Application\Responder;
44

55
use Psr\Http\Message\ResponseInterface;
66
use Slim\Interfaces\RouteParserInterface;

0 commit comments

Comments
 (0)