src/Entity/Help.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. /**
  9.  * @ORM\Table(name="fs_help")
  10.  * @ORM\Entity
  11.  */
  12. class Help
  13. {
  14.     function helpLocale($locale){
  15.         foreach($this->translations as $trans){
  16.             if($trans->getLanguage()->getSign() == $locale)
  17.                 return $trans;
  18.         }
  19.     }
  20.     /**
  21.      * @ORM\Column(name="id", type="bigint")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     protected $id;
  26.     /**
  27.      * @ORM\Column(name="slug", type="string")
  28.      */
  29.     protected $slug;
  30.     // ONE TO MANY
  31.         /**
  32.          * @ORM\OneToMany(targetEntity="App\Entity\HelpTranslation", mappedBy="help")
  33.          */
  34.         private $translations;
  35.     //
  36.     public function __construct()
  37.     {
  38.         $this->translations = new ArrayCollection();
  39.     }
  40.     public function getId(): ?string
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getSlug(): ?string
  45.     {
  46.         return $this->slug;
  47.     }
  48.     public function setSlug(string $slug): self
  49.     {
  50.         $this->slug $slug;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection<int, HelpTranslation>
  55.      */
  56.     public function getTranslations(): Collection
  57.     {
  58.         return $this->translations;
  59.     }
  60.     public function addTranslation(HelpTranslation $translation): self
  61.     {
  62.         if (!$this->translations->contains($translation)) {
  63.             $this->translations->add($translation);
  64.             $translation->setHelp($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeTranslation(HelpTranslation $translation): self
  69.     {
  70.         if ($this->translations->removeElement($translation)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($translation->getHelp() === $this) {
  73.                 $translation->setHelp(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78. }