modification classe offre et gateway

offres2
Baptiste D 1 year ago
parent 4bc8b49b31
commit 51d4223a09

@ -132,14 +132,13 @@ class UtilisateurControleur
$imgMdl = new ImageModele; $imgMdl = new ImageModele;
$offreMdl = new OffreModele(); $offreMdl = new OffreModele();
$imgid = $imgMdl->publierImage(); $img = $imgMdl->publierImage();
$offreMdl->publierOffre($imgid); $offreMdl->publierOffre($img);
global $twig;
echo $twig->render('Offres.html', [$offreMdl->getOffres()]);
} }
protected function testAction() protected function testAction()
{ {
echo "test action "; echo "test action ";

@ -1,6 +1,7 @@
<?php <?php
namespace App\gateway; namespace App\gateway;
use App\metier\Alumni;
use App\metier\Offre; use App\metier\Offre;
class OffreGateway class OffreGateway
{ {
@ -50,4 +51,21 @@ class OffreGateway
':remote' => array($offre->isRemote(), \PDO::PARAM_BOOL) ':remote' => array($offre->isRemote(), \PDO::PARAM_BOOL)
)); ));
} }
public function obtenirOffres() : string
{
$alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test"));
$query = 'SELECT * FROM Offre';
$this->con->executeQuery($query, array());
$res = $this->con->getResults();
$offres = array();
foreach ($res as $row)
{
$alumni = $alGw->findById($row['offreur']);
$offre = new Offre($row['id'], $alumni, $row['nom'], $row['description'], $row['imgId'], $row['typeContrat'], $row['ville'], $row['descriptifPoste'], $row['profil'], $row['experience'], $row['niveauEtudes'], $row['mailContact'], $row['numero'], $row['siteUrl'], $row['remote']);
array_push($offres, $offre);
}
return $offres;
}
} }

@ -88,7 +88,7 @@ class Offre
//private \App\metier\NiveauEtudes $niveauEtudes; //private \App\metier\NiveauEtudes $niveauEtudes;
private string $niveauEtudes; private string $niveauEtudes;
private int $imgId; private Image $img;
/** /**
* @var string Email de contact * @var string Email de contact
@ -128,7 +128,7 @@ class Offre
Alumni $offreur, Alumni $offreur,
string $nom, string $nom,
string $description, string $description,
int $imgId, Image $imgId,
string $typeContrat, string $typeContrat,
//\App\metier\TypeContrat $typeContrat, //\App\metier\TypeContrat $typeContrat,
string $ville, string $ville,
@ -188,7 +188,7 @@ class Offre
public function getImgId(): int public function getImgId(): int
{ {
return $this->imgId; return $this->img->getId();
} }
public function getTypeContrat(): string public function getTypeContrat(): string

@ -13,7 +13,7 @@ class ImageModele
$this->gw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica","test","test")); $this->gw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica","test","test"));
} }
public function publierImage() public function publierImage() : Image
{ {
$img = new Image($this->gw->getNewId(), $img = new Image($this->gw->getNewId(),
$_FILES["image"]["name"], $_FILES["image"]["name"],
@ -23,7 +23,7 @@ class ImageModele
$this->gw->insertImage($img); $this->gw->insertImage($img);
return $this->gw->trouverParNom($img->getName())->getId(); return $img;
} }
public function insertImage(Image $img) public function insertImage(Image $img)

@ -8,6 +8,7 @@ use App\metier\Alumni;
use App\metier\TypeContrat; use App\metier\TypeContrat;
use App\metier\niveauEtudes; use App\metier\niveauEtudes;
use App\metier\Offre; use App\metier\Offre;
use App\metier\Image;
class OffreModele class OffreModele
{ {
@ -19,7 +20,7 @@ class OffreModele
$this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); $this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test"));
} }
public function publierOffre($imgId) public function publierOffre(Image $img)
{ {
$desc = $_POST["description"]; $desc = $_POST["description"];
@ -63,7 +64,7 @@ class OffreModele
new Alumni(12,"test.mail@icloud.fr","password","admin"), new Alumni(12,"test.mail@icloud.fr","password","admin"),
$nom, $nom,
$desc, $desc,
$imgId, $img,
$typeContrat, $typeContrat,
$ville, $ville,
$entreprise, $entreprise,
@ -80,5 +81,10 @@ class OffreModele
echo "offre inséerée"; echo "offre inséerée";
} }
public function obtenirOffres() : array
{
$offres = $this->offreGw->getOffres();
return $offres;
}
} }
Loading…
Cancel
Save