Commit 48a3f457 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Correction signature de fonction + recussion du remplacement de macro

parent b94b3323
Pipeline #11627 passed with stage
in 21 seconds
...@@ -145,12 +145,14 @@ class RenduService { ...@@ -145,12 +145,14 @@ class RenduService {
* @param array $variables * @param array $variables
* @return Rendu * @return Rendu
*/ */
public function genereateRenduByTemplateCode(string $code, array $variables) : Rendu public function generateRenduByTemplateCode(string $code, array $variables) : Rendu
{ {
$template = $this->getTemplateService()->getTemplateByCode($code); $template = $this->getTemplateService()->getTemplateByCode($code);
if ($template === null) throw new RuntimeException('Aucun template de trouvé avec le code ['.$code.']'); if ($template === null) throw new RuntimeException('Aucun template de trouvé avec le code ['.$code.']');
$rendu = $this->generateRenduByTemplate($template, $variables); $rendu = $this->generateRenduByTemplate($template, $variables);
//todo faire mieux pour rappliquer
$rendu->setCorps($this->getTemplateService()->replaceMacros($rendu->getCorps(), $variables));
return $rendu; return $rendu;
} }
} }
...@@ -149,7 +149,7 @@ class TemplateService { ...@@ -149,7 +149,7 @@ class TemplateService {
* @param array $variables * @param array $variables
* @return string * @return string
*/ */
private function replaceMacros(string $texteInitial, array $variables) : string public function replaceMacros(string $texteInitial, array $variables) : string
{ {
$matches = []; $matches = [];
preg_match_all('/VAR\[[a-zA-Z0-9_]*#[a-zA-Z0-9_]*\]/', $texteInitial, $matches); preg_match_all('/VAR\[[a-zA-Z0-9_]*#[a-zA-Z0-9_]*\]/', $texteInitial, $matches);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment