Skip to content
Snippets Groups Projects
Commit df062f51 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout de la possibilité de ne pas sauvegarder un contenu

parent e852c49f
Branches
Tags
No related merge requests found
Pipeline #19321 passed
......@@ -106,7 +106,7 @@ class RenduService
/** facade ********************************************************************************************************/
public function generateRenduByTemplate(Template $template, array $variables): Rendu
public function generateRenduByTemplate(Template $template, array $variables, bool $save = true): Rendu
{
$contenu = new Rendu();
$contenu->setTemplate($template);
......@@ -117,20 +117,22 @@ class RenduService
$corps = $this->getTemplateService()->generateCorps($template, $variables);
$contenu->setCorps($corps);
if ($save) {
$this->create($contenu);
}
return $contenu;
}
/**
* TODO >>> faire mieux pour rappliquer
*/
public function generateRenduByTemplateCode(string $code, array $variables): Rendu
public function generateRenduByTemplateCode(string $code, array $variables, bool $save = true): Rendu
{
$template = $this->getTemplateService()->getTemplateByCode($code);
if ($template === null) throw new RuntimeException('Aucun template de trouvé avec le code [' . $code . ']');
$rendu = $this->generateRenduByTemplate($template, $variables);
$rendu->setCorps($this->getTemplateService()->replaceMacros($rendu->getCorps(), $variables));
$rendu->setCorps($this->getTemplateService()->replaceMacros($rendu->getCorps(), $variables, $save));
return $rendu;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment