1,13 → 1,41 |
<?php |
class NomDecorateur { |
class NomDecorateur implements NomResponsabilite { |
protected $nom = null; |
protected $nomFormate = array(); |
private $detailsHrefTpl = null; |
protected $correspondances = array( |
'id' => 'Id', |
'nom_sci' => 'Intitule', |
'href' => 'Href', |
'auteur' => 'Auteur', |
'annee' => 'Annee', |
'biblio_origine' => 'Biblio', |
'nom_addendum' => 'Addendum', |
'notes' => 'Notes', |
'homonyme' => 'Homonyme'); |
|
public function __construct(NomDO $nomADecorer) { |
public function __construct(NomDO $nomADecorer, $detailsHrefTpl) { |
$this->nom = $nomADecorer; |
$this->detailsHrefTpl = $detailsHrefTpl; |
$this->initialiserNomFormate(); |
} |
|
public function traiterChampsRetour(Array $champsRetour) { |
foreach ($champsRetour as $champ) { |
if (array_key_exists($champ, $this->correspondances)) { |
$methodesAExecuter = explode(',', $this->correspondances[$champ]); |
foreach ($methodesAExecuter as $methodeNom) { |
$methodeAjouter = 'ajouter'.$methodeNom; |
if (method_exists($this, $methodeAjouter)) { |
$this->$methodeAjouter(); |
unset($champsRetour[$champ]); |
} |
} |
} |
} |
return $champsRetour; |
} |
|
public function ajouterId() { |
$this->nomFormate['id'] = (int) $this->nom->getTag('num_nom'); |
} |
16,6 → 44,13 |
$this->nomFormate['nom_sci'] = $this->nom->getTag('nom_sci'); |
} |
|
public function ajouterHref() { |
if ($this->nom->verifierTag('num_nom')) { |
$href = sprintf($this->detailsHrefTpl, $this->nom->getTag('num_nom')); |
$this->nomFormate['href'] = $href; |
} |
} |
|
public function ajouterAuteur() { |
if ($this->nom->verifierTag('auteur')) { |
$this->nomFormate['auteur'] = $this->nom->getTag('auteur'); |