modification classe offre et gateway

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

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

@ -1,6 +1,7 @@
<?php
namespace App\gateway;
use App\metier\Alumni;
use App\metier\Offre;
class OffreGateway
{
@ -50,4 +51,21 @@ class OffreGateway
':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 string $niveauEtudes;
private int $imgId;
private Image $img;
/**
* @var string Email de contact
@ -128,7 +128,7 @@ class Offre
Alumni $offreur,
string $nom,
string $description,
int $imgId,
Image $imgId,
string $typeContrat,
//\App\metier\TypeContrat $typeContrat,
string $ville,
@ -188,7 +188,7 @@ class Offre
public function getImgId(): int
{
return $this->imgId;
return $this->img->getId();
}
public function getTypeContrat(): string

@ -13,7 +13,7 @@ class ImageModele
$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(),
$_FILES["image"]["name"],
@ -23,7 +23,7 @@ class ImageModele
$this->gw->insertImage($img);
return $this->gw->trouverParNom($img->getName())->getId();
return $img;
}
public function insertImage(Image $img)

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