antikhonov / cashapp

0 stars 0 forks source link

Add user id to domain entities #1

Open antikhonov opened 9 years ago

antikhonov commented 9 years ago

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:

  1. Create parent class for all domain entities, eg. UserEntity;
  2. Require user id in all constructors to avoid creating of unowned entities;
  3. 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']
});

Got it from here: http://help.slimframework.com/discussions/questions/747-variable-avaliable-in-all-application-context

antikhonov commented 9 years ago

User ids are now required in all domain entity constructors. Will do for now.

antikhonov commented 9 years ago

Had to modify DB search logic to add user id to all search requests of UserEntity type