diff --git a/README.md b/README.md index c30d8b76..62a5de65 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ templates. With frontend [**slim-starter**](https://github.com/samuelgfeller/slim-starter) or just for an API: [**slim-api-starter**](https://github.com/samuelgfeller/slim-api-starter). -Please read the [**installation guide**](https://samuel-gfeller.ch/docs/Installation-Guide) +Please read the [**installation guide**](https://samuel-gfeller.ch/docs/Slim-Example-Project-Installation-Guide) to get started. ## Features diff --git a/config/container.php b/config/container.php index fb0422b1..3c03b935 100644 --- a/config/container.php +++ b/config/container.php @@ -5,6 +5,7 @@ * Documentation: https://samuel-gfeller.ch/docs/Dependency-Injection. */ +use App\Application\Data\UserNetworkSessionData; use App\Infrastructure\Utility\Settings; use Cake\Database\Connection; use Monolog\Formatter\LineFormatter; @@ -187,4 +188,8 @@ return $eventDispatcher; }, + // Add shared UserNetworkSessionData to the container so that the DTO can be populated and used in different places + UserNetworkSessionData::class => function () { + return new UserNetworkSessionData(); + } ]; diff --git a/src/Application/Middleware/UserNetworkSessionDataMiddleware.php b/src/Application/Middleware/UserNetworkSessionDataMiddleware.php index 6561d615..0b44db73 100644 --- a/src/Application/Middleware/UserNetworkSessionDataMiddleware.php +++ b/src/Application/Middleware/UserNetworkSessionDataMiddleware.php @@ -16,6 +16,9 @@ final readonly class UserNetworkSessionDataMiddleware implements MiddlewareInterface { public function __construct( + // The UserNetworkSessionData DTO object is registered and created in the container definition + // container.php so that this middleware can populate it with data that are also available + // by any service that also injects this DTO object. private UserNetworkSessionData $clientNetworkData, private SessionInterface $session, ) {