|
|
@ -2,12 +2,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace model;
|
|
|
|
namespace model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use DAL\ArticleGateway;
|
|
|
|
|
|
|
|
use DAL\FluxGateway;
|
|
|
|
use DOMDocument;
|
|
|
|
use DOMDocument;
|
|
|
|
use metier\Article;
|
|
|
|
use metier\Article;
|
|
|
|
use metier\Flux;
|
|
|
|
use metier\Flux;
|
|
|
|
|
|
|
|
|
|
|
|
class Parser
|
|
|
|
class Parser
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private FluxGateway $fluxGateway;
|
|
|
|
|
|
|
|
private ArticleGateway $articleGateway;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(FluxGateway $fluxGateway, ArticleGateway $articleGateway){
|
|
|
|
|
|
|
|
$this->fluxGateway = $fluxGateway;
|
|
|
|
|
|
|
|
$this->articleGateway = $articleGateway;
|
|
|
|
|
|
|
|
}
|
|
|
|
public function parseArticles(Flux $flux){
|
|
|
|
public function parseArticles(Flux $flux){
|
|
|
|
$dom = new DOMDocument();
|
|
|
|
$dom = new DOMDocument();
|
|
|
|
$tabArticle = array();
|
|
|
|
$tabArticle = array();
|
|
|
@ -33,10 +42,20 @@ class Parser
|
|
|
|
return $tabArticle;
|
|
|
|
return $tabArticle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function parseAll(Flux $fluxes){
|
|
|
|
public function parseAll($fluxes){
|
|
|
|
foreach ($fluxes as $flux){
|
|
|
|
foreach ($fluxes as $flux){
|
|
|
|
$tabArticles[] =$this->parseArticles($flux);
|
|
|
|
$tabArticles[] =$this->parseArticles($flux);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $tabArticles;
|
|
|
|
return $tabArticles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function addAllArticles(){
|
|
|
|
|
|
|
|
$allFlux = $this->fluxGateway->findAllFlux();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$allArticles = $this->parseAll($allFlux);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($allArticles as $article) {
|
|
|
|
|
|
|
|
$this->articleGateway->addArticle($article);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|