<?php
namespace App\Service;
use App\Entity\Text;
class TextHelper
{
public function __construct(\Doctrine\ORM\EntityManager $em)
{
$this->em = $em;
}
public function getBySection($section)
{
$text = [];
if ($section) {
$textos = $this->em->getRepository(Text::Class)->findBy(['section' => $section]);
if ($textos) {
foreach ($textos as $value) {
$text[$value->getCode()] = $value->getText();
}
}
}
return $text;
}
public function getByCode($code)
{
$text = [];
if ($code) {
$texto = $this->em->getRepository(Text::Class)->findOneBy(['code' => $code]);
if($texto){
$text[$texto->getCode()] = $texto->getText();
}
}
return $text;
}
}