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; namespace Manager;
use Model\User;
use Stub\AuthService;
class CoachManager class CoachManager
{ {
private User currentUser;
function __construct() { function __construct() {
if (isset(authService->currentUser)) {
this->currentUser = authService->currentUser;
}
} }
} }

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

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

Loading…
Cancel
Save