src/Entity/Webfactory/Actualites/WebfactoryActualite.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Webfactory\Actualites;
  3. use App\Repository\Webfactory\Actualites\WebfactoryActualiteRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Table(name'webfactory_actualite')]
  9. #[ORM\Entity(repositoryClassWebfactoryActualiteRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class WebfactoryActualite
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private ?int $id null;
  17.     #[ORM\Column(type'string'length255)]
  18.     private string $adherent;
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private ?string $author;
  21.     #[ORM\Column(type'datetime_immutable')]
  22.     private DateTimeImmutable $created_at;
  23.     #[ORM\Column(type'datetime_immutable')]
  24.     private DateTimeImmutable $updated_at;
  25.     #[ORM\Column(type'boolean')]
  26.     private bool $active;
  27.     #[ORM\Column(type'boolean'nullabletrue)]
  28.     private ?bool $lockCopie;
  29.     #[ORM\OneToMany(mappedBy'article'targetEntityWebfactoryActualiteContenu::class,  cascade: ['persist''remove'])]
  30.     private Collection $webfactoryActualiteContenus;
  31.     #[ORM\ManyToOne(inversedBy'webfactoryActualites')]
  32.     private ?WebfactoryActualiteBibliotheque $actualiteBibliotheque null;
  33.     #[ORM\ManyToOne(inversedBy'webfactoryActualites')]
  34.     private ?WebfactoryActualiteCategory $actualiteCategory null;
  35.     public function toArray(): array
  36.     {
  37.         return get_object_vars($this);
  38.     }
  39.     public function __construct()
  40.     {
  41.         $this->webfactoryActualiteContenus = new ArrayCollection();
  42.         $this->created_at = new DateTimeImmutable("now");
  43.         $this->updated_at = new DateTimeImmutable("now");
  44.         $this->active true;
  45.     }
  46.     #[ORM\PreUpdate]
  47.     public function onPreUpdateEntity(): void
  48.     {
  49.         $this->updated_at = new \DateTimeImmutable('now');
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function setId(?int $id): void
  56.     {
  57.         $this->id $id;
  58.     }
  59.     public function getAdherent(): ?string
  60.     {
  61.         return $this->adherent;
  62.     }
  63.     public function setAdherent(string $adherent): self
  64.     {
  65.         $this->adherent $adherent;
  66.         return $this;
  67.     }
  68.     public function getAuthor(): ?string
  69.     {
  70.         return $this->author;
  71.     }
  72.     public function setAuthor(?string $author): self
  73.     {
  74.         $this->author $author;
  75.         return $this;
  76.     }
  77.     public function getCreatedAt(): ?DateTimeImmutable
  78.     {
  79.         return $this->created_at;
  80.     }
  81.     public function setCreatedAt(DateTimeImmutable $created_at): self
  82.     {
  83.         $this->created_at $created_at;
  84.         return $this;
  85.     }
  86.     public function getUpdatedAt(): ?DateTimeImmutable
  87.     {
  88.         return $this->updated_at;
  89.     }
  90.     public function setUpdatedAt(DateTimeImmutable $updated_at): self
  91.     {
  92.         $this->updated_at $updated_at;
  93.         return $this;
  94.     }
  95.     public function isActive(): ?bool
  96.     {
  97.         return $this->active;
  98.     }
  99.     public function setActive(bool $active): self
  100.     {
  101.         $this->active $active;
  102.         return $this;
  103.     }
  104.     public function isLockCopie(): ?bool
  105.     {
  106.         return $this->lockCopie;
  107.     }
  108.     public function setLockCopie(?bool $lockCopie): self
  109.     {
  110.         $this->lockCopie $lockCopie;
  111.         return $this;
  112.     }
  113.     /**
  114.      * @return Collection<int, WebfactoryActualiteContenu>
  115.      */
  116.     public function getWebfactoryActualiteContenus(): Collection
  117.     {
  118.         return $this->webfactoryActualiteContenus;
  119.     }
  120.     public function addWebfactoryActualiteContenu(WebfactoryActualiteContenu $webfactoryActualiteContenu): static
  121.     {
  122.         if (!$this->webfactoryActualiteContenus->contains($webfactoryActualiteContenu)) {
  123.             $this->webfactoryActualiteContenus->add($webfactoryActualiteContenu);
  124.             $webfactoryActualiteContenu->setArticle($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeWebfactoryActualiteContenu(WebfactoryActualiteContenu $webfactoryActualiteContenu): static
  129.     {
  130.         if ($this->webfactoryActualiteContenus->removeElement($webfactoryActualiteContenu)) {
  131.             // set the owning side to null (unless already changed)
  132.             if ($webfactoryActualiteContenu->getArticle() === $this) {
  133.                 $webfactoryActualiteContenu->setArticle(null);
  134.             }
  135.         }
  136.         return $this;
  137.     }
  138.     public function getActualiteBibliotheque(): ?WebfactoryActualiteBibliotheque
  139.     {
  140.         return $this->actualiteBibliotheque;
  141.     }
  142.     public function setActualiteBibliotheque(?WebfactoryActualiteBibliotheque $actualiteBibliotheque): static
  143.     {
  144.         $this->actualiteBibliotheque $actualiteBibliotheque;
  145.         return $this;
  146.     }
  147.     public function getActualiteCategory(): ?WebfactoryActualiteCategory
  148.     {
  149.         return $this->actualiteCategory;
  150.     }
  151.     public function setActualiteCategory(?WebfactoryActualiteCategory $actualiteCategory): static
  152.     {
  153.         $this->actualiteCategory $actualiteCategory;
  154.         return $this;
  155.     }
  156.     public function getContenuByLang($lang)
  157.     {
  158.         foreach ($this->webfactoryActualiteContenus as $articleContenu) {
  159.             if (strtolower($articleContenu->getLang()) === strtolower($lang)) {
  160.                 return $articleContenu;
  161.             }
  162.         }
  163.         return null;
  164.     }
  165. }