diff --git a/fluxRSS/metier/Article.php b/fluxRSS/metier/Article.php index 50a6370..809c3d1 100755 --- a/fluxRSS/metier/Article.php +++ b/fluxRSS/metier/Article.php @@ -4,26 +4,26 @@ namespace metier; class Article { - private int $id; + private string $id; private string $title; private string $date; private string $description; private string $guid; private string $link; private string $mediaContent; - private int $provenance; + private string $provenance; /** - * @param int $id + * @param string $id * @param string $title * @param string $date * @param string $description * @param string $guid * @param string $link * @param string $mediaContent - * @param int $provenance + * @param string $provenance */ - public function __construct(int $id, string $title, string $date, string $description, string $guid, string $link, string $mediaContent, int $provenance) + public function __construct(string $id, string $title, string $date, string $description, string $guid, string $link, string $mediaContent, string $provenance) { $this->id = $id; $this->title = $title; @@ -115,4 +115,9 @@ class Article $this->provenance = $provenance; } + public function __toString(): string + { + return $this->title . $this->date . $this->description; + } + } \ No newline at end of file diff --git a/fluxRSS/model/ArticleModel.php b/fluxRSS/model/ArticleModel.php index 4134ff9..d8e24e8 100755 --- a/fluxRSS/model/ArticleModel.php +++ b/fluxRSS/model/ArticleModel.php @@ -2,21 +2,23 @@ namespace model; -use DAL\{AdminGateway, ArticleGateway, Connection}; -use metier; +use DAL\{ArticleGateway, Connection}; +use Exception; +use metier\Article; class ArticleModel { + /** + * @throws Exception + */ public static function getArticles() : array { - $gwArticle = new ArticleGateway(new Connection('mysql:host=londres.uca.local ; dbname=dbrorossetto', 'rorossetto', 'tpphp')); + $gwArticle = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp')); $tabArticle = array(); $res = $gwArticle->getAllArticles(); foreach($res as $row){ - $tabArticle[] = new metier\Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] ); + $tabArticle[] = new Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] ); } return $tabArticle; } -} - -var_dump(ArticleModel::getArticles()); \ No newline at end of file +} \ No newline at end of file diff --git a/fluxRSS/templates/listArticle.html b/fluxRSS/templates/listArticle.html index c3dbaa6..0852fc3 100755 --- a/fluxRSS/templates/listArticle.html +++ b/fluxRSS/templates/listArticle.html @@ -5,7 +5,7 @@
{{value}}
{% endfor %}