Skip to content

Commit

Permalink
Changement dans le nom des fonctions pour surcharger une template.
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Sep 6, 2020
1 parent 597e0a8 commit 337f087
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
38 changes: 34 additions & 4 deletions src/Components/Template/Template.php
Expand Up @@ -292,27 +292,57 @@ public function render()
}

/**
* Ajoute un nom de fichier.
* Défini les noms de fichier de remplacement.
*
* @param array $names
*
* @return $this
*/
public function setNamesOverride(array $names)
{
$this->nameOverride = $names;

return $this;
}

/**
* Ajoute un nom de fichier de remplacement.
*
* @param string $name
*
* @return $this
*/
public function nameOverride($name)
public function addNameOverride($name)
{
$this->nameOverride[] = $name;

return $this;
}

/**
* Ajoute un chemin.
* Ajoute des noms de fichier de remplacement.
*
* @param array $names
*
* @return $this
*/
public function addNamesOverride(array $names)
{
foreach ($names as $name) {
$this->addNameOverride($name);
}

return $this;
}

/**
* Ajoute un chemin de remplacement.
*
* @param string $name
*
* @return $this
*/
public function pathOverride($name)
public function addPathOverride($name)
{
$this->pathOverride[] = $name;

Expand Down
8 changes: 4 additions & 4 deletions tests/Components/Template/TemplateTest.php
Expand Up @@ -137,7 +137,7 @@ public function testOverride()
{
/* Override PATH */
$page = new Template('testBlock.php', $this->pathTemplate);
$page->pathOverride($this->pathTemplate . 'theme/');
$page->addPathOverride($this->pathTemplate . 'theme/');
$this->object->addVar('attr', 'Test')
->addBlock('page', $page)
->addBlock('title');
Expand All @@ -146,7 +146,7 @@ public function testOverride()

/* Override NAME */
$page = new Template('testBlock.php', $this->pathTemplate);
$page->nameOverride('testBlock_1.php');
$page->addNameOverride('testBlock_1.php');
$this->object->addVar('attr', 'Test')
->addBlock('page', $page)
->addBlock('title');
Expand All @@ -155,8 +155,8 @@ public function testOverride()

/* Override PATH & NAME */
$page = new Template('testBlock.php', $this->pathTemplate);
$page->pathOverride($this->pathTemplate . 'theme/')
->nameOverride('testBlock_1.php');
$page->addPathOverride($this->pathTemplate . 'theme/')
->addNameOverride('testBlock_1.php');
$this->object->addVar('attr', 'Test')
->addBlock('page', $page)
->addBlock('title');
Expand Down

0 comments on commit 337f087

Please sign in to comment.