initialized Coach US
continuous-integration/drone/push Build is passing Details

issue_16_statistics_coach
Antoine PEREDERII 1 year ago
parent eec7dfb069
commit 91422418ed

@ -0,0 +1,7 @@
<?php
namespace model;
class CoachAthlete extends Coach {
}

@ -2,9 +2,15 @@
namespace Manager;
use Model\User;
use Stub\AuthService;
class CoachManager
{
private User currentUser;
function __construct() {
if (isset(authService->currentUser)) {
this->currentUser = authService->currentUser;
}
}
}

@ -7,9 +7,11 @@ use Stub\UserRepository;
class StubData extends DataManager{
public function __construct(){
$this->userMgr = new UserManager(new AuthService(new UserRepository(),new HashPassword()));
if($this->userMgr->currentUser->Role)
$this->coachMgr = new CoachManager();
$userRepository = new \Stub\UserRepository();
$authService = new \Stub\AuthService($userRepository,new HashPassword());
$this->userMgr = new UserManager($authService);
// if($this->userMgr->currentUser->Role ) // is an instance of ...
$this->coachMgr->currentUser = new CoachManager($authService);
// if(user.Role is instance of Coach) {
// this->CoachMgr = new CoachManager();
// }

@ -11,6 +11,9 @@ use Stub\UserRepository;
class AuthService implements IAuthService {
private $userRepository;
private $passwordHasher;
private $currentUser;
public function __construct(UserRepository $userRepository, IHashPassword $passwordHasher) {
$this->userRepository = $userRepository;
$this->passwordHasher = $passwordHasher;
@ -23,7 +26,7 @@ class AuthService implements IAuthService {
throw new \Exception('Unable to find user with that name');
}
if ($user->isValidPassword($password)) {
return $user;
return this->currentUser = $user;
}
return null;
}

Loading…
Cancel
Save