src/Entity/CBRCPageContent.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CBRCPageContentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CBRCPageContentRepository::class)
  10.  * @UniqueEntity(fields="name", message="La page existe déjà")
  11.  */
  12. class CBRCPageContent
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="text", nullable=true)
  26.      */
  27.     private $content;
  28.     /**
  29.      * @ORM\Column(type="datetime")
  30.      */
  31.     private $lastupdate;
  32.     /**
  33.      * @ORM\OneToMany(targetEntity=CBRCPageContentUpdate::class, mappedBy="page", orphanRemoval=true)
  34.      */
  35.     private $pagecontentupdates;
  36.     public function __construct()
  37.     {
  38.         $this->pagecontentupdates = new ArrayCollection();
  39.         $this->lastupdate = new \DateTime('now');
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     public function getContent(): ?string
  55.     {
  56.         return $this->content;
  57.     }
  58.     public function setContent(?string $content): self
  59.     {
  60.         $this->content $content;
  61.         $this->setLastupdate(new \DateTime('now'));
  62.         return $this;
  63.     }
  64.     public function getLastupdate(): ?\DateTimeInterface
  65.     {
  66.         return $this->lastupdate;
  67.     }
  68.     public function setLastupdate(\DateTimeInterface $lastupdate): self
  69.     {
  70.         $this->lastupdate $lastupdate;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection|CBRCPageContentUpdate[]
  75.      */
  76.     public function getPagecontentupdates(): Collection
  77.     {
  78.         return $this->pagecontentupdates;
  79.     }
  80.     public function addPagecontentupdate(CBRCPageContentUpdate $pagecontentupdate): self
  81.     {
  82.         if (!$this->pagecontentupdates->contains($pagecontentupdate)) {
  83.             $this->pagecontentupdates[] = $pagecontentupdate;
  84.             $pagecontentupdate->setPage($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removePagecontentupdate(CBRCPageContentUpdate $pagecontentupdate): self
  89.     {
  90.         if ($this->pagecontentupdates->removeElement($pagecontentupdate)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($pagecontentupdate->getPage() === $this) {
  93.                 $pagecontentupdate->setPage(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98. }