From d4345678992503b9eb56ef4afd00ff13f5d7531a Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 23 Oct 2023 17:12:10 +0200 Subject: [PATCH] oui --- .../DiagrammeCasUtilisationFitWeb.drawio | 0 Sources/composer.json | 12 +++- Sources/src/console/Console.php | 12 +++- Sources/src/data/model/Coach.php | 5 +- Sources/src/data/model/User.php | 29 +++++++++ .../src/data/model/manager/DataManager.php | 1 + .../data/model/repository/IUserRepository.php | 7 +++ Sources/src/data/stub/StubData.php | 1 - .../data/stub/repository/UserRepository.php | 17 +++--- Sources/src/data/stub/service/AuthService.php | 2 +- Sources/vendor/composer/autoload_psr4.php | 11 +++- Sources/vendor/composer/autoload_static.php | 59 ++++++++++++++++++- 12 files changed, 137 insertions(+), 19 deletions(-) rename Documents/Diagramme/{ => Annalyse/Besoins}/DiagrammeCasUtilisationFitWeb.drawio (100%) create mode 100644 Sources/src/data/model/repository/IUserRepository.php diff --git a/Documents/Diagramme/DiagrammeCasUtilisationFitWeb.drawio b/Documents/Diagramme/Annalyse/Besoins/DiagrammeCasUtilisationFitWeb.drawio similarity index 100% rename from Documents/Diagramme/DiagrammeCasUtilisationFitWeb.drawio rename to Documents/Diagramme/Annalyse/Besoins/DiagrammeCasUtilisationFitWeb.drawio diff --git a/Sources/composer.json b/Sources/composer.json index e8d8f5a2..28e24d23 100644 --- a/Sources/composer.json +++ b/Sources/composer.json @@ -3,8 +3,16 @@ "autoload": { "psr-4": { "Hearttrack\\": "src/", - "Console\\":"src/console", - "Stub\\":"src/data/stub" + "App\\": "src/app", + "Data\\": "src/data", + "Console\\": "src/console", + "Model\\": "src/data/model", + "Repository\\": "src/data/model/repository", + "Manager\\": "src/data/model/manager", + "Stub\\": "src/data/stub", + "Service\\": "src/data/stub/service", + "Core\\": "src/data/core", + "Network\\": "src/data/core/network" } }, diff --git a/Sources/src/console/Console.php b/Sources/src/console/Console.php index deaa512c..a1824fc3 100755 --- a/Sources/src/console/Console.php +++ b/Sources/src/console/Console.php @@ -1,5 +1,12 @@ #!/usr/bin/env php + \ No newline at end of file diff --git a/Sources/src/data/model/Coach.php b/Sources/src/data/model/Coach.php index 31ed1f51..84281064 100644 --- a/Sources/src/data/model/Coach.php +++ b/Sources/src/data/model/Coach.php @@ -1,7 +1,8 @@ id}, Nom: {$this->nom}, Prénom: {$this->prenom}, Email: {$this->email}]"; + } + +} \ No newline at end of file diff --git a/Sources/src/data/model/manager/DataManager.php b/Sources/src/data/model/manager/DataManager.php index 68f70011..17d4f223 100644 --- a/Sources/src/data/model/manager/DataManager.php +++ b/Sources/src/data/model/manager/DataManager.php @@ -4,6 +4,7 @@ namespace Manager; abstract class DataManager { + public $userMgr; } diff --git a/Sources/src/data/model/repository/IUserRepository.php b/Sources/src/data/model/repository/IUserRepository.php new file mode 100644 index 00000000..a7db2304 --- /dev/null +++ b/Sources/src/data/model/repository/IUserRepository.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/Sources/src/data/stub/StubData.php b/Sources/src/data/stub/StubData.php index 8c778ebc..7e55e7b8 100644 --- a/Sources/src/data/stub/StubData.php +++ b/Sources/src/data/stub/StubData.php @@ -3,7 +3,6 @@ namespace Stub; use Manager\DataManager; use Manager\UserManager; class StubData extends DataManager{ - public $userMgr; public function __construct(){ $userMgr = new UserManager(new AuthService(new UserRepository())); } diff --git a/Sources/src/data/stub/repository/UserRepository.php b/Sources/src/data/stub/repository/UserRepository.php index 6aab6cd6..3437eaab 100644 --- a/Sources/src/data/stub/repository/UserRepository.php +++ b/Sources/src/data/stub/repository/UserRepository.php @@ -2,21 +2,20 @@ namespace Stub; -use Model\IGenericRepository; +use Model\Athlete; +use Model\Coach; use Model\IUserRepository; -use Model\Role; use Model\User; -class UserRepository implements IGenericRepository,IUserRepository { +class UserRepository implements IUserRepository { private array $users = []; public function __construct() { - // Ajout de 5 utilisateurs pour l'exemple - $this->users[] = new User(1, "Doe", "John", "john.doe@example.com", "password123", new Role("Coach")); - $this->users[] = new User(2, "Smith", "Jane", "jane.smith@example.com", "secure456", new Role("User")); - $this->users[] = new User(3, "Martin", "Paul", "paul.martin@example.com", "super789", new Role("Coach")); - $this->users[] = new User(4, "Brown", "Anna", "anna.brown@example.com", "test000", new Role("User")); - $this->users[] = new User(5, "Lee", "Bruce", "bruce.lee@example.com", "hello321", new Role("User")); + $this->users[] = new User(1, "Doe", "John", "john.doe@example.com", "password123", "Masculin", 1.80, 75, new \DateTime("1985-05-15"), new Coach()); + $this->users[] = new User(2, "Smith", "Jane", "jane.smith@example.com", "secure456", "Féminin", 1.65, 60, new \DateTime("1990-03-10"), new Athlete()); + $this->users[] = new User(3, "Martin", "Paul", "paul.martin@example.com", "super789", "Masculin", 1.75, 68, new \DateTime("1988-08-20"), new Coach()); + $this->users[] = new User(4, "Brown", "Anna", "anna.brown@example.com", "test000", "Féminin", 1.70, 58, new \DateTime("1992-11-25"), new Athlete()); + $this->users[] = new User(5, "Lee", "Bruce", "bruce.lee@example.com", "hello321", "Masculin", 1.72, 70, new \DateTime("1970-02-05"), new Athlete()); } public function getItemById(int $id): ?User { diff --git a/Sources/src/data/stub/service/AuthService.php b/Sources/src/data/stub/service/AuthService.php index 902a1fde..f1d3a4d9 100644 --- a/Sources/src/data/stub/service/AuthService.php +++ b/Sources/src/data/stub/service/AuthService.php @@ -13,7 +13,7 @@ class AuthService implements IAuthService { public function login($username, $password) { - $user = $this->userRepository->getUserByUsername($username); + $user = $this->userRepository->GetItemByName($username,0,1); if (!$user) { throw new \Exception('Unable to find user with that name'); diff --git a/Sources/vendor/composer/autoload_psr4.php b/Sources/vendor/composer/autoload_psr4.php index 6676c0ae..4c1e8198 100644 --- a/Sources/vendor/composer/autoload_psr4.php +++ b/Sources/vendor/composer/autoload_psr4.php @@ -9,9 +9,18 @@ return array( 'Twig\\' => array($vendorDir . '/twig/twig/src'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), + 'Stub\\' => array($baseDir . '/src/data/stub'), + 'Service\\' => array($baseDir . '/src/data/stub/service'), + 'Repository\\' => array($baseDir . '/src/data/model/repository'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), + 'Network\\' => array($baseDir . '/src/data/core/network'), + 'Model\\' => array($baseDir . '/src/data/model'), + 'Manager\\' => array($baseDir . '/src/data/model/manager'), 'Hearttrack\\' => array($baseDir . '/src'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'), - 'Console\\' => array($baseDir . '/src/Console'), + 'Data\\' => array($baseDir . '/src/data'), + 'Core\\' => array($baseDir . '/src/data/core'), + 'Console\\' => array($baseDir . '/src/console'), + 'App\\' => array($baseDir . '/src/app'), ); diff --git a/Sources/vendor/composer/autoload_static.php b/Sources/vendor/composer/autoload_static.php index b4852ed3..b60e4b55 100644 --- a/Sources/vendor/composer/autoload_static.php +++ b/Sources/vendor/composer/autoload_static.php @@ -22,11 +22,26 @@ class ComposerStaticInitb084bad56d99d613841073027e5f5e7e array ( 'Symfony\\Polyfill\\Mbstring\\' => 26, 'Symfony\\Polyfill\\Ctype\\' => 23, + 'Stub\\' => 5, + 'Service\\' => 8, + ), + 'R' => + array ( + 'Repository\\' => 11, ), 'P' => array ( 'PhpParser\\' => 10, ), + 'N' => + array ( + 'Network\\' => 8, + ), + 'M' => + array ( + 'Model\\' => 6, + 'Manager\\' => 8, + ), 'H' => array ( 'Hearttrack\\' => 11, @@ -35,11 +50,17 @@ class ComposerStaticInitb084bad56d99d613841073027e5f5e7e array ( 'Doctrine\\Instantiator\\' => 22, 'DeepCopy\\' => 9, + 'Data\\' => 5, ), 'C' => array ( + 'Core\\' => 5, 'Console\\' => 8, ), + 'A' => + array ( + 'App\\' => 4, + ), ); public static $prefixDirsPsr4 = array ( @@ -55,10 +76,34 @@ class ComposerStaticInitb084bad56d99d613841073027e5f5e7e array ( 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', ), + 'Stub\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/stub', + ), + 'Service\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/stub/service', + ), + 'Repository\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/model/repository', + ), 'PhpParser\\' => array ( 0 => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser', ), + 'Network\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/core/network', + ), + 'Model\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/model', + ), + 'Manager\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/model/manager', + ), 'Hearttrack\\' => array ( 0 => __DIR__ . '/../..' . '/src', @@ -71,9 +116,21 @@ class ComposerStaticInitb084bad56d99d613841073027e5f5e7e array ( 0 => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy', ), + 'Data\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data', + ), + 'Core\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/data/core', + ), 'Console\\' => array ( - 0 => __DIR__ . '/../..' . '/src/Console', + 0 => __DIR__ . '/../..' . '/src/console', + ), + 'App\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/app', ), );