<?phpnamespace App\Entity\Webfactory\Actualites;use App\Repository\Webfactory\Actualites\WebfactoryActualiteRepository;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Table(name: 'webfactory_actualite')]#[ORM\Entity(repositoryClass: WebfactoryActualiteRepository::class)]#[ORM\HasLifecycleCallbacks]class WebfactoryActualite{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 255)] private string $adherent; #[ORM\Column(type: 'string', length: 255, nullable: true)] private ?string $author; #[ORM\Column(type: 'datetime_immutable')] private DateTimeImmutable $created_at; #[ORM\Column(type: 'datetime_immutable')] private DateTimeImmutable $updated_at; #[ORM\Column(type: 'boolean')] private bool $active; #[ORM\Column(type: 'boolean', nullable: true)] private ?bool $lockCopie; #[ORM\OneToMany(mappedBy: 'article', targetEntity: WebfactoryActualiteContenu::class, cascade: ['persist', 'remove'])] private Collection $webfactoryActualiteContenus; #[ORM\ManyToOne(inversedBy: 'webfactoryActualites')] private ?WebfactoryActualiteBibliotheque $actualiteBibliotheque = null; #[ORM\ManyToOne(inversedBy: 'webfactoryActualites')] private ?WebfactoryActualiteCategory $actualiteCategory = null; public function toArray(): array { return get_object_vars($this); } public function __construct() { $this->webfactoryActualiteContenus = new ArrayCollection(); $this->created_at = new DateTimeImmutable("now"); $this->updated_at = new DateTimeImmutable("now"); $this->active = true; } #[ORM\PreUpdate] public function onPreUpdateEntity(): void { $this->updated_at = new \DateTimeImmutable('now'); } 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): self { $this->adherent = $adherent; return $this; } public function getAuthor(): ?string { return $this->author; } public function setAuthor(?string $author): self { $this->author = $author; return $this; } public function getCreatedAt(): ?DateTimeImmutable { return $this->created_at; } public function setCreatedAt(DateTimeImmutable $created_at): self { $this->created_at = $created_at; return $this; } public function getUpdatedAt(): ?DateTimeImmutable { return $this->updated_at; } public function setUpdatedAt(DateTimeImmutable $updated_at): self { $this->updated_at = $updated_at; return $this; } public function isActive(): ?bool { return $this->active; } public function setActive(bool $active): self { $this->active = $active; return $this; } public function isLockCopie(): ?bool { return $this->lockCopie; } public function setLockCopie(?bool $lockCopie): self { $this->lockCopie = $lockCopie; return $this; } /** * @return Collection<int, WebfactoryActualiteContenu> */ public function getWebfactoryActualiteContenus(): Collection { return $this->webfactoryActualiteContenus; } public function addWebfactoryActualiteContenu(WebfactoryActualiteContenu $webfactoryActualiteContenu): static { if (!$this->webfactoryActualiteContenus->contains($webfactoryActualiteContenu)) { $this->webfactoryActualiteContenus->add($webfactoryActualiteContenu); $webfactoryActualiteContenu->setArticle($this); } return $this; } public function removeWebfactoryActualiteContenu(WebfactoryActualiteContenu $webfactoryActualiteContenu): static { if ($this->webfactoryActualiteContenus->removeElement($webfactoryActualiteContenu)) { // set the owning side to null (unless already changed) if ($webfactoryActualiteContenu->getArticle() === $this) { $webfactoryActualiteContenu->setArticle(null); } } return $this; } public function getActualiteBibliotheque(): ?WebfactoryActualiteBibliotheque { return $this->actualiteBibliotheque; } public function setActualiteBibliotheque(?WebfactoryActualiteBibliotheque $actualiteBibliotheque): static { $this->actualiteBibliotheque = $actualiteBibliotheque; return $this; } public function getActualiteCategory(): ?WebfactoryActualiteCategory { return $this->actualiteCategory; } public function setActualiteCategory(?WebfactoryActualiteCategory $actualiteCategory): static { $this->actualiteCategory = $actualiteCategory; return $this; } public function getContenuByLang($lang) { foreach ($this->webfactoryActualiteContenus as $articleContenu) { if (strtolower($articleContenu->getLang()) === strtolower($lang)) { return $articleContenu; } } return null; }}