src/Entity/Webfactory/Actualites/WebfactoryActualiteCategory.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Webfactory\Actualites;
  3. use App\Repository\Webfactory\Actualites\WebfactoryActualiteCategoryRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassWebfactoryActualiteCategoryRepository::class)]
  9. class WebfactoryActualiteCategory
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $adherent null;
  17.     #[ORM\Column]
  18.     private ?DateTimeImmutable $created_at;
  19.     #[ORM\Column]
  20.     private ?DateTimeImmutable $updated_at;
  21.     #[ORM\OneToMany(mappedBy'webfactory_category'targetEntityWebfactoryActualiteCategoryContenu::class, cascade: ['persist''remove'])]
  22.     private Collection $webfactoryActualiteCategoryContenus;
  23.     #[ORM\OneToMany(mappedBy'actualiteCategory'targetEntityWebfactoryActualite::class)]
  24.     private Collection $webfactoryActualites;
  25.     #[ORM\OneToMany(mappedBy'webfactoryCategory'targetEntityWebfactoryActualiteBibliotheque::class)]
  26.     private Collection $webfactoryActualiteBibliotheques;
  27.     public function __construct()
  28.     {
  29.         $this->webfactoryActualiteCategoryContenus = new ArrayCollection();
  30.         $this->webfactoryActualites = new ArrayCollection();
  31.         $this->created_at = new DateTimeImmutable("now");
  32.         $this->updated_at = new DateTimeImmutable("now");
  33.         $this->webfactoryActualiteBibliotheques = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function setId(?int $id): void
  40.     {
  41.         $this->id $id;
  42.     }
  43.     public function getAdherent(): ?string
  44.     {
  45.         return $this->adherent;
  46.     }
  47.     public function setAdherent(string $adherent): static
  48.     {
  49.         $this->adherent $adherent;
  50.         return $this;
  51.     }
  52.     public function getCreatedAt(): ?DateTimeImmutable
  53.     {
  54.         return $this->created_at;
  55.     }
  56.     public function setCreatedAt(DateTimeImmutable $created_at): static
  57.     {
  58.         $this->created_at $created_at;
  59.         return $this;
  60.     }
  61.     public function getUpdatedAt(): ?DateTimeImmutable
  62.     {
  63.         return $this->updated_at;
  64.     }
  65.     public function setUpdatedAt(DateTimeImmutable $updated_at): static
  66.     {
  67.         $this->updated_at $updated_at;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, WebfactoryActualiteCategoryContenu>
  72.      */
  73.     public function getWebfactoryActualiteCategoryContenus(): Collection
  74.     {
  75.         return $this->webfactoryActualiteCategoryContenus;
  76.     }
  77.     public function addWebfactoryActualiteCategoryContenu(WebfactoryActualiteCategoryContenu $webfactoryActualiteCategoryContenu): static
  78.     {
  79.         if (!$this->webfactoryActualiteCategoryContenus->contains($webfactoryActualiteCategoryContenu)) {
  80.             $this->webfactoryActualiteCategoryContenus->add($webfactoryActualiteCategoryContenu);
  81.             $webfactoryActualiteCategoryContenu->setWebfactoryCategory($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeWebfactoryActualiteCategoryContenu(WebfactoryActualiteCategoryContenu $webfactoryActualiteCategoryContenu): static
  86.     {
  87.         if ($this->webfactoryActualiteCategoryContenus->removeElement($webfactoryActualiteCategoryContenu)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($webfactoryActualiteCategoryContenu->getWebfactoryCategory() === $this) {
  90.                 $webfactoryActualiteCategoryContenu->setWebfactoryCategory(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return Collection<int, WebfactoryActualite>
  97.      */
  98.     public function getWebfactoryActualites(): Collection
  99.     {
  100.         return $this->webfactoryActualites;
  101.     }
  102.     public function addWebfactoryActualite(WebfactoryActualite $webfactoryActualite): static
  103.     {
  104.         if (!$this->webfactoryActualites->contains($webfactoryActualite)) {
  105.             $this->webfactoryActualites->add($webfactoryActualite);
  106.             $webfactoryActualite->setActualiteCategory($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removeWebfactoryActualite(WebfactoryActualite $webfactoryActualite): static
  111.     {
  112.         if ($this->webfactoryActualites->removeElement($webfactoryActualite)) {
  113.             // set the owning side to null (unless already changed)
  114.             if ($webfactoryActualite->getActualiteCategory() === $this) {
  115.                 $webfactoryActualite->setActualiteCategory(null);
  116.             }
  117.         }
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, WebfactoryActualiteBibliotheque>
  122.      */
  123.     public function getWebfactoryActualiteBibliotheques(): Collection
  124.     {
  125.         return $this->webfactoryActualiteBibliotheques;
  126.     }
  127.     public function addWebfactoryActualiteBibliotheque(WebfactoryActualiteBibliotheque $webfactoryActualiteBibliotheque): static
  128.     {
  129.         if (!$this->webfactoryActualiteBibliotheques->contains($webfactoryActualiteBibliotheque)) {
  130.             $this->webfactoryActualiteBibliotheques->add($webfactoryActualiteBibliotheque);
  131.             $webfactoryActualiteBibliotheque->setWebfactoryCategory($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeWebfactoryActualiteBibliotheque(WebfactoryActualiteBibliotheque $webfactoryActualiteBibliotheque): static
  136.     {
  137.         if ($this->webfactoryActualiteBibliotheques->removeElement($webfactoryActualiteBibliotheque)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($webfactoryActualiteBibliotheque->getWebfactoryCategory() === $this) {
  140.                 $webfactoryActualiteBibliotheque->setWebfactoryCategory(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     public function getContenuByLang($lang)
  146.     {
  147.         foreach ($this->webfactoryActualiteCategoryContenus as $categContenu) {
  148.             if (strtolower($categContenu->getLang()) === strtolower($lang)) {
  149.                 return $categContenu;
  150.             }
  151.         }
  152.     }
  153.     public function __toString(): string
  154.     {
  155.         $return "";
  156.         foreach ($this->webfactoryActualiteCategoryContenus as $key => $contenu) {
  157.             $return .= $contenu->getName();
  158.             if ($key count($this->webfactoryActualiteCategoryContenus) - 1) {
  159.                 $return .= ' / ';
  160.             }
  161.         }
  162.         return $return;
  163.     }
  164. }