Need to add user id to the domain entities. The goal is to link accoutnts, transactions and some categories to particular users. Now I can think of the following implementation:
Create parent class for all domain entities, eg. UserEntity;
Require user id in all constructors to avoid creating of unowned entities;
In the Auth Slim middleware store user id in the environmental variable (see example below);
$env = $app->environment();
$env['userData'] = $userData;
$app->get('/', function() use ($app) {
$env = $app->environment();
// do something with $env['userData']
});
Need to add user id to the domain entities. The goal is to link accoutnts, transactions and some categories to particular users. Now I can think of the following implementation:
Got it from here: http://help.slimframework.com/discussions/questions/747-variable-avaliable-in-all-application-context