<?php
namespace App\Entity;
use App\Repository\CBRCPageContentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=CBRCPageContentRepository::class)
* @UniqueEntity(fields="name", message="La page existe déjà")
*/
class CBRCPageContent
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="datetime")
*/
private $lastupdate;
/**
* @ORM\OneToMany(targetEntity=CBRCPageContentUpdate::class, mappedBy="page", orphanRemoval=true)
*/
private $pagecontentupdates;
public function __construct()
{
$this->pagecontentupdates = new ArrayCollection();
$this->lastupdate = new \DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
$this->setLastupdate(new \DateTime('now'));
return $this;
}
public function getLastupdate(): ?\DateTimeInterface
{
return $this->lastupdate;
}
public function setLastupdate(\DateTimeInterface $lastupdate): self
{
$this->lastupdate = $lastupdate;
return $this;
}
/**
* @return Collection|CBRCPageContentUpdate[]
*/
public function getPagecontentupdates(): Collection
{
return $this->pagecontentupdates;
}
public function addPagecontentupdate(CBRCPageContentUpdate $pagecontentupdate): self
{
if (!$this->pagecontentupdates->contains($pagecontentupdate)) {
$this->pagecontentupdates[] = $pagecontentupdate;
$pagecontentupdate->setPage($this);
}
return $this;
}
public function removePagecontentupdate(CBRCPageContentUpdate $pagecontentupdate): self
{
if ($this->pagecontentupdates->removeElement($pagecontentupdate)) {
// set the owning side to null (unless already changed)
if ($pagecontentupdate->getPage() === $this) {
$pagecontentupdate->setPage(null);
}
}
return $this;
}
}