src/Service/TextHelper.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Entity\Text;
  4. class TextHelper
  5. {
  6.    public function __construct(\Doctrine\ORM\EntityManager $em)
  7.    {
  8.       $this->em $em;
  9.    }
  10.    public function getBySection($section)
  11.    {
  12.       $text = [];
  13.       if ($section) {
  14.          $textos $this->em->getRepository(Text::Class)->findBy(['section' => $section]);
  15.          if ($textos) {
  16.             foreach ($textos as $value) {
  17.                $text[$value->getCode()] = $value->getText();
  18.             }
  19.          }
  20.       }
  21.       return $text;
  22.    }
  23.    public function getByCode($code)
  24.    {
  25.       $text = [];
  26.       if ($code) {
  27.          $texto                   $this->em->getRepository(Text::Class)->findOneBy(['code' => $code]);
  28.          if($texto){
  29.             $text[$texto->getCode()] = $texto->getText();
  30.          }
  31.       }
  32.       return $text;
  33.    }
  34. }