<?phpnamespace App\Entity\Webfactory\Actualites;use App\Repository\Webfactory\Actualites\WebfactoryActualiteCategoryRepository;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: WebfactoryActualiteCategoryRepository::class)]class WebfactoryActualiteCategory{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $adherent = null; #[ORM\Column] private ?DateTimeImmutable $created_at; #[ORM\Column] private ?DateTimeImmutable $updated_at; #[ORM\OneToMany(mappedBy: 'webfactory_category', targetEntity: WebfactoryActualiteCategoryContenu::class, cascade: ['persist', 'remove'])] private Collection $webfactoryActualiteCategoryContenus; #[ORM\OneToMany(mappedBy: 'actualiteCategory', targetEntity: WebfactoryActualite::class)] private Collection $webfactoryActualites; #[ORM\OneToMany(mappedBy: 'webfactoryCategory', targetEntity: WebfactoryActualiteBibliotheque::class)] private Collection $webfactoryActualiteBibliotheques; public function __construct() { $this->webfactoryActualiteCategoryContenus = new ArrayCollection(); $this->webfactoryActualites = new ArrayCollection(); $this->created_at = new DateTimeImmutable("now"); $this->updated_at = new DateTimeImmutable("now"); $this->webfactoryActualiteBibliotheques = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setId(?int $id): void { $this->id = $id; } public function getAdherent(): ?string { return $this->adherent; } public function setAdherent(string $adherent): static { $this->adherent = $adherent; return $this; } public function getCreatedAt(): ?DateTimeImmutable { return $this->created_at; } public function setCreatedAt(DateTimeImmutable $created_at): static { $this->created_at = $created_at; return $this; } public function getUpdatedAt(): ?DateTimeImmutable { return $this->updated_at; } public function setUpdatedAt(DateTimeImmutable $updated_at): static { $this->updated_at = $updated_at; return $this; } /** * @return Collection<int, WebfactoryActualiteCategoryContenu> */ public function getWebfactoryActualiteCategoryContenus(): Collection { return $this->webfactoryActualiteCategoryContenus; } public function addWebfactoryActualiteCategoryContenu(WebfactoryActualiteCategoryContenu $webfactoryActualiteCategoryContenu): static { if (!$this->webfactoryActualiteCategoryContenus->contains($webfactoryActualiteCategoryContenu)) { $this->webfactoryActualiteCategoryContenus->add($webfactoryActualiteCategoryContenu); $webfactoryActualiteCategoryContenu->setWebfactoryCategory($this); } return $this; } public function removeWebfactoryActualiteCategoryContenu(WebfactoryActualiteCategoryContenu $webfactoryActualiteCategoryContenu): static { if ($this->webfactoryActualiteCategoryContenus->removeElement($webfactoryActualiteCategoryContenu)) { // set the owning side to null (unless already changed) if ($webfactoryActualiteCategoryContenu->getWebfactoryCategory() === $this) { $webfactoryActualiteCategoryContenu->setWebfactoryCategory(null); } } return $this; } /** * @return Collection<int, WebfactoryActualite> */ public function getWebfactoryActualites(): Collection { return $this->webfactoryActualites; } public function addWebfactoryActualite(WebfactoryActualite $webfactoryActualite): static { if (!$this->webfactoryActualites->contains($webfactoryActualite)) { $this->webfactoryActualites->add($webfactoryActualite); $webfactoryActualite->setActualiteCategory($this); } return $this; } public function removeWebfactoryActualite(WebfactoryActualite $webfactoryActualite): static { if ($this->webfactoryActualites->removeElement($webfactoryActualite)) { // set the owning side to null (unless already changed) if ($webfactoryActualite->getActualiteCategory() === $this) { $webfactoryActualite->setActualiteCategory(null); } } return $this; } /** * @return Collection<int, WebfactoryActualiteBibliotheque> */ public function getWebfactoryActualiteBibliotheques(): Collection { return $this->webfactoryActualiteBibliotheques; } public function addWebfactoryActualiteBibliotheque(WebfactoryActualiteBibliotheque $webfactoryActualiteBibliotheque): static { if (!$this->webfactoryActualiteBibliotheques->contains($webfactoryActualiteBibliotheque)) { $this->webfactoryActualiteBibliotheques->add($webfactoryActualiteBibliotheque); $webfactoryActualiteBibliotheque->setWebfactoryCategory($this); } return $this; } public function removeWebfactoryActualiteBibliotheque(WebfactoryActualiteBibliotheque $webfactoryActualiteBibliotheque): static { if ($this->webfactoryActualiteBibliotheques->removeElement($webfactoryActualiteBibliotheque)) { // set the owning side to null (unless already changed) if ($webfactoryActualiteBibliotheque->getWebfactoryCategory() === $this) { $webfactoryActualiteBibliotheque->setWebfactoryCategory(null); } } return $this; } public function getContenuByLang($lang) { foreach ($this->webfactoryActualiteCategoryContenus as $categContenu) { if (strtolower($categContenu->getLang()) === strtolower($lang)) { return $categContenu; } } } public function __toString(): string { $return = ""; foreach ($this->webfactoryActualiteCategoryContenus as $key => $contenu) { $return .= $contenu->getName(); if ($key < count($this->webfactoryActualiteCategoryContenus) - 1) { $return .= ' / '; } } return $return; }}