From e6a8a556c5012f713af7368b563318f14e4490be Mon Sep 17 00:00:00 2001 From: "anthony.richard" Date: Sat, 11 Nov 2023 14:05:10 +0100 Subject: [PATCH] =?UTF-8?q?plus=20besoin=20de=20mettre=20de=20param=C3=A8t?= =?UTF-8?q?res=20$con=20dans=20les=20gateways?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/gateway/AbsGateway.php | 7 +++++-- Project/php/gateway/GroupGateway.php | 4 ++-- Project/php/gateway/UserGateway.php | 4 ++-- Project/php/gateway/VocabularyGateway.php | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Project/php/gateway/AbsGateway.php b/Project/php/gateway/AbsGateway.php index 2d47f38..0b3ebfc 100755 --- a/Project/php/gateway/AbsGateway.php +++ b/Project/php/gateway/AbsGateway.php @@ -10,8 +10,11 @@ abstract class AbsGateway { protected Connection $con; - public function __construct(Connection $con) { - $this->con = $con; + public function __construct() { + global $dsn; + global $login; + global $password; + $this->con = new Connection($dsn, $login, $password); } public abstract function add(array $parameters): int; diff --git a/Project/php/gateway/GroupGateway.php b/Project/php/gateway/GroupGateway.php index f089c1f..3cae42d 100755 --- a/Project/php/gateway/GroupGateway.php +++ b/Project/php/gateway/GroupGateway.php @@ -10,8 +10,8 @@ use model\Group; class GroupGateway extends AbsGateway { - public function __construct(Connection $con){ - parent::__construct($con); + public function __construct(){ + parent::__construct(); } public function add(array $parameters): int //require 4 elements diff --git a/Project/php/gateway/UserGateway.php b/Project/php/gateway/UserGateway.php index 273b761..fcb5557 100755 --- a/Project/php/gateway/UserGateway.php +++ b/Project/php/gateway/UserGateway.php @@ -9,9 +9,9 @@ use Exception; class UserGateway extends AbsGateway { - public function __construct(Connection $con) + public function __construct() { - parent::__construct($con); + parent::__construct(); } public function add(array $parameters): int //require 9 elements diff --git a/Project/php/gateway/VocabularyGateway.php b/Project/php/gateway/VocabularyGateway.php index 4aee47e..b0ed969 100755 --- a/Project/php/gateway/VocabularyGateway.php +++ b/Project/php/gateway/VocabularyGateway.php @@ -3,13 +3,13 @@ namespace gateway; use PDO; use PDOException; -use config\Connection; +use Exception; use model\Vocabulary; class VocabularyGateway extends AbsGateway { - public function __construct(Connection $con){ - parent::__construct($con); + public function __construct(){ + parent::__construct(); } public function add(array $parameters): int // require 4 elements