Skip to content

Commit

Permalink
Renamed renderer folder to responder [SLE-192]
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgfeller committed Mar 28, 2024
1 parent 5034a7a commit 71039ef
Show file tree
Hide file tree
Showing 52 changed files with 113 additions and 162 deletions.
5 changes: 4 additions & 1 deletion config/middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$app->add(SessionStartMiddleware::class);

// Cors middleware has to be before routing so that it is performed after routing (LIFO)
// $app->add(CorsMiddleware::class); // Middleware added in api group in routes.php
// $app->add(CorsOldMiddleware::class); // Middleware added in api group in routes.php

// Has to be after phpViewExtensionMiddleware https://www.slimframework.com/docs/v4/cookbook/retrieving-current-route.html
// The RoutingMiddleware should be added after our CORS middleware
Expand All @@ -49,4 +49,7 @@
$app->add(NonFatalErrorHandlerMiddleware::class);
// Set error handler to custom DefaultErrorHandler (defined in container.php)
$app->add(ErrorMiddleware::class);

// Cross-Origin Resource Sharing (CORS) middleware. Allow other domains to access the API
$app->add(\App\Application\Middleware\CorsMiddleware::class);
};
13 changes: 2 additions & 11 deletions config/routes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use App\Application\Middleware\CorsMiddleware;
use App\Application\Middleware\UserAuthenticationMiddleware;
use Slim\App;
use Slim\Exception\HttpNotFoundException;
Expand All @@ -21,7 +20,7 @@
$group->options('/clients', function ($request, $response) {
return $response;
});
})->add(CorsMiddleware::class);
})->add(\App\Application\Middleware\CorsMiddleware::class);

$app->put('/dashboard-toggle-panel', \App\Application\Action\Dashboard\DashboardTogglePanelProcessAction::class)
->setName('dashboard-toggle-panel');
Expand Down Expand Up @@ -139,12 +138,6 @@
->setName('note-submit-delete');
})->add(UserAuthenticationMiddleware::class);

// $app->get( '/favicon.ico', function ($request, $response) {
// $response->getBody()->write('https://samuel-gfeller.ch/wp-content/uploads/2020/08/cropped-favicon_small-32x32.png');
//
// return $response;
// });

/**
* Catch-all route to serve a 404 Not Found page if none of the routes match
* NOTE: make sure this route is defined last.
Expand All @@ -155,9 +148,7 @@
function ($request, $response) {
throw new HttpNotFoundException(
$request,
'Route "' . $request->getUri()->getHost() . $request->getUri()->getPath() .
'" not found.'
// <br>Basepath: "' . $app->getBasePath() . '"'
'Route "' . $request->getUri()->getHost() . $request->getUri()->getPath() . '" not found.'
);
}
);
Expand Down
4 changes: 2 additions & 2 deletions resources/seeds/AdminUserSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getDependencies(): array
*/
public function run(): void
{
$userData = [
$userRows = [
[
'first_name' => 'Admin',
'surname' => 'Admin',
Expand All @@ -41,6 +41,6 @@ public function run(): void
];

$table = $this->table('user');
$table->insert($userData)->saveData();
$table->insert($userRows)->saveData();
}
}
22 changes: 11 additions & 11 deletions resources/seeds/ClientSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function run(): void
$oneDayAgo = $now->sub(new \DateInterval('P01D'))->format('Y-m-d H:i:s');
$oneWeekAgo = $now->sub(new \DateInterval('P08D'))->format('Y-m-d H:i:s');

$data = [
$rows = [
[
'id' => 1,
'first_name' => 'Gary',
Expand Down Expand Up @@ -207,23 +207,23 @@ public function run(): void
];

$table = $this->table('client');
$table->insert($data)->saveData();
$table->insert($rows)->saveData();

// Insert user_activity
$userActivityData = [];
$userActivityRows = [];
// If user created client, an entry is made in user_activity table
foreach ($data as $clientData) {
foreach ($rows as $clientRows) {
// If client_message is empty, it means that a user created the client entry
if ($clientData['client_message'] === null) {
$userActivityData[] = [
'user_id' => $clientData['user_id'],
if ($clientRows['client_message'] === null) {
$userActivityRows[] = [
'user_id' => $clientRows['user_id'],
'action' => 'created',
'table' => 'client',
'row_id' => $clientData['id'],
'row_id' => $clientRows['id'],
// json encode relevant keys (all of ClientData->toArrayForDatabase)
'data' => json_encode(
array_intersect_key(
$clientData,
$clientRows,
array_flip([
'first_name',
'last_name',
Expand All @@ -240,7 +240,7 @@ public function run(): void
),
JSON_THROW_ON_ERROR
),
'datetime' => $clientData['created_at'],
'datetime' => $clientRows['created_at'],
'ip_address' => '127.0.0.1',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, ' .
'like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54',
Expand All @@ -249,6 +249,6 @@ public function run(): void
}
// Insert user activity
$table = $this->table('user_activity');
$table->insert($userActivityData)->saveData();
$table->insert($userActivityRows)->saveData();
}
}
4 changes: 2 additions & 2 deletions resources/seeds/ClientStatusSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ClientStatusSeeder extends AbstractSeed
*/
public function run(): void
{
$clientStatusData = [
$clientStatusRows = [
['name' => 'Action pending'],
['name' => 'Helped'],
['name' => 'In care'],
Expand All @@ -24,6 +24,6 @@ public function run(): void

$table = $this->table('client_status');

$table->insert($clientStatusData)->saveData();
$table->insert($clientStatusRows)->saveData();
}
}
22 changes: 11 additions & 11 deletions resources/seeds/NoteSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function run(): void
$oneDayAgo = $now->sub(new \DateInterval('P01D'))->format('Y-m-d H:i:s');
$oneWeekAgo = $now->sub(new \DateInterval('P07D'))->format('Y-m-d H:i:s');

$data = [
// 1 Gary Preble 2 I have been struggling with addiction to drugs for a long time and I need help to overcome it.
$rows = [
// 1 Gary Preble 2 I have been struggling with addiction to drugs for a long time and I need help to overcome it.
[
'id' => 1,
'user_id' => 2,
Expand Down Expand Up @@ -306,30 +306,30 @@ public function run(): void
];

$table = $this->table('note');
$table->insert($data)->saveData();
$table->insert($rows)->saveData();

// Insert user_activity
$userActivityData = [];
$userActivityRows = [];
// If user created client, an entry is made in user_activity table
foreach ($data as $noteData) {
$userActivityData[] = [
'user_id' => $noteData['user_id'],
foreach ($rows as $noteRows) {
$userActivityRows[] = [
'user_id' => $noteRows['user_id'],
'action' => 'created',
'table' => 'note',
'row_id' => $noteData['id'],
'row_id' => $noteRows['id'],
// json encode relevant keys (all of ClientData->toArrayForDatabase)
'data' => json_encode(
array_intersect_key($noteData, array_flip(['message', 'client_id', 'user_id', 'is_main',])),
array_intersect_key($noteRows, array_flip(['message', 'client_id', 'user_id', 'is_main',])),
JSON_THROW_ON_ERROR
),
'datetime' => $noteData['created_at'] ?? $oneWeekAgo,
'datetime' => $noteRows['created_at'] ?? $oneWeekAgo,
'ip_address' => '127.0.0.1',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, ' .
'like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54',
];
}
// Insert user activity
$table = $this->table('user_activity');
$table->insert($userActivityData)->saveData();
$table->insert($userActivityRows)->saveData();
}
}
4 changes: 2 additions & 2 deletions resources/seeds/UserFilterSettingSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getDependencies(): array
public function run(): void
{
// Insert dashboard user filter seeder so that the front page is less empty
$data = [
$rows = [
[
'user_id' => 1,
'filter_id' => 'assigned-to-me-panel',
Expand All @@ -54,6 +54,6 @@ public function run(): void
];

$table = $this->table('user_filter_setting');
$table->insert($data)->saveData();
$table->insert($rows)->saveData();
}
}
4 changes: 2 additions & 2 deletions resources/seeds/UserRoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserRoleSeeder extends AbstractSeed
*/
public function run(): void
{
$userRoleData = [
$userRoleRows = [
['id' => 1, 'name' => 'admin', 'hierarchy' => 1],
['id' => 2, 'name' => 'managing_advisor', 'hierarchy' => 2],
['id' => 3, 'name' => 'advisor', 'hierarchy' => 3],
Expand All @@ -24,6 +24,6 @@ public function run(): void

$table = $this->table('user_role');

$table->insert($userRoleData)->saveData();
$table->insert($userRoleRows)->saveData();
}
}
4 changes: 2 additions & 2 deletions resources/seeds/UserSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getDependencies(): array
*/
public function run(): void
{
$userData = [
$userRows = [
[
'id' => 2,
'first_name' => 'Managing-advisor',
Expand Down Expand Up @@ -65,6 +65,6 @@ public function run(): void
];

$table = $this->table('user');
$table->insert($userData)->saveData();
$table->insert($userRows)->saveData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Authentication\Ajax;

use App\Application\Renderer\RedirectHandler;
use App\Application\Responder\RedirectHandler;
use App\Domain\Authentication\Exception\InvalidTokenException;
use App\Domain\Authentication\Exception\UserAlreadyVerifiedException;
use App\Domain\Authentication\Service\AccountUnlockTokenVerifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Application\Action\Authentication\Ajax;

use App\Application\Renderer\RedirectHandler;
use App\Application\Renderer\TemplateRenderer;
use App\Application\Responder\RedirectHandler;
use App\Application\Responder\TemplateRenderer;
use App\Domain\Authentication\Exception\InvalidCredentialsException;
use App\Domain\Authentication\Exception\UnableToLoginStatusNotActiveException;
use App\Domain\Authentication\Service\LoginVerifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Application\Action\Authentication\Ajax;

use App\Application\Renderer\RedirectHandler;
use App\Application\Renderer\TemplateRenderer;
use App\Application\Responder\RedirectHandler;
use App\Application\Responder\TemplateRenderer;
use App\Domain\Authentication\Exception\InvalidTokenException;
use App\Domain\Authentication\Service\PasswordResetterWithToken;
use App\Domain\Validation\ValidationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Application\Action\Authentication\Ajax;

use App\Application\Renderer\RedirectHandler;
use App\Application\Renderer\TemplateRenderer;
use App\Application\Responder\RedirectHandler;
use App\Application\Responder\TemplateRenderer;
use App\Domain\Authentication\Service\PasswordRecoveryEmailSender;
use App\Domain\Exception\DomainRecordNotFoundException;
use App\Domain\Security\Exception\SecurityException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Authentication\Ajax;

use App\Application\Renderer\RedirectHandler;
use App\Application\Responder\RedirectHandler;
use App\Domain\Authentication\Exception\InvalidTokenException;
use App\Domain\Authentication\Exception\UserAlreadyVerifiedException;
use App\Domain\Authentication\Service\RegisterTokenVerifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Application\Action\Authentication\Page;

use App\Application\Renderer\RedirectHandler;
use App\Application\Renderer\TemplateRenderer;
use App\Application\Responder\RedirectHandler;
use App\Application\Responder\TemplateRenderer;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Authentication\Page;

use App\Application\Renderer\RedirectHandler;
use App\Application\Responder\RedirectHandler;
use Odan\Session\SessionInterface;
use Odan\Session\SessionManagerInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Authentication\Page;

use App\Application\Renderer\TemplateRenderer;
use App\Application\Responder\TemplateRenderer;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Ajax;

use App\Application\Renderer\JsonEncoder;
use App\Application\Responder\JsonEncoder;
use App\Domain\Client\Service\ClientCreatorFromApi;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Action/Client/Ajax/ClientCreateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Ajax;

use App\Application\Renderer\JsonEncoder;
use App\Application\Responder\JsonEncoder;
use App\Domain\Client\Service\ClientCreator;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Action/Client/Ajax/ClientDeleteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Ajax;

use App\Application\Renderer\JsonEncoder;
use App\Application\Responder\JsonEncoder;
use App\Domain\Client\Service\ClientDeleter;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Ajax;

use App\Application\Renderer\JsonEncoder;
use App\Application\Responder\JsonEncoder;
use App\Domain\Client\Exception\InvalidClientFilterException;
use App\Domain\Client\Service\ClientFinderWithFilter;
use App\Test\Integration\Client\ClientListActionTest;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Action/Client/Ajax/ClientUpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Ajax;

use App\Application\Renderer\JsonEncoder;
use App\Application\Responder\JsonEncoder;
use App\Domain\Client\Service\ClientUpdater;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Ajax;

use App\Application\Renderer\JsonEncoder;
use App\Application\Responder\JsonEncoder;
use App\Domain\Client\Service\ClientUtilFinder;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Application\Action\Client\Page;

use App\Application\Renderer\TemplateRenderer;
use App\Application\Responder\TemplateRenderer;
use App\Domain\Authorization\Privilege;
use App\Domain\Client\Service\Authorization\ClientPermissionVerifier;
use App\Domain\Client\Service\ClientListFilter\ClientListFilterChipProvider;
Expand Down
Loading

0 comments on commit 71039ef

Please sign in to comment.