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

Correction + fonction dans service de recherche par type

parent a295568d
No related branches found
No related tags found
No related merge requests found
......@@ -21,9 +21,9 @@ class ContenuController extends AbstractActionController {
$contenuNames = []; $attachements = []; $types = [];
foreach ($contenus as $contenu) {
$contenuNames[$contenu->getCode()] = $contenu->getCode();
$attachements[$contenu->getAttachement()] = $contenu->getAttachement();
$types[$contenu->getType()] = $contenu->getType();
if ($contenu->getCode()) $contenuNames[$contenu->getCode()] = $contenu->getCode();
if ($contenu->getAttachement()) $attachements[$contenu->getAttachement()] = $contenu->getAttachement();
if ($contenu->getType()) $types[$contenu->getType()] = $contenu->getType();
}
$contenuName = $this->params()->fromQuery('contenuName');
......
......@@ -94,6 +94,21 @@ class ContenuService {
return $result;
}
/**
* @param string $type
* @return Content[]
*/
public function getContenusByType(string $type) : array
{
$qb = $this->createQueryBuilder()
->andWhere('contenu.type = :type')
->setParameter('type', $type)
;
$result = $qb->getQuery()->getResult();
return $result;
}
/**
* @param integer $id
* @return Content
......@@ -152,7 +167,7 @@ class ContenuService {
* @param array $variables
* @return string
*/
private function replaceMacros($texteInitial, $variables)
private function replaceMacros(string $texteInitial, array $variables) : string
{
$matches = [];
preg_match_all('/VAR\[[a-z,A-Z,0-9,#,_]*\]/', $texteInitial, $matches);
......@@ -172,7 +187,7 @@ class ContenuService {
* @param array $variables
* @return string
*/
public function generateComplement($contenu, $variables)
public function generateComplement(Content $contenu, array $variables) : string
{
return $this->replaceMacros($contenu->getComplement(), $variables);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment