src/Entity/Page.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\ActiveConstants;
  4. use App\Repository\PageRepository;
  5. use App\Traits\ActivityTrait;
  6. use App\Traits\MetaImageTrait;
  7. use App\Traits\MetaTrait;
  8. use App\Traits\SlugTrait;
  9. use App\Traits\TimeTrackTrait;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. #[ORM\Entity(repositoryClassPageRepository::class)]
  16. #[ORM\Table(name'page')]
  17. #[ORM\HasLifecycleCallbacks]
  18. class Page
  19. {
  20.     use ActivityTrait;
  21.     use MetaImageTrait;
  22.     use MetaTrait;
  23.     use SlugTrait;
  24.     use TimeTrackTrait;
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     private ?int $id null;
  29.     #[Assert\NotNull]
  30.     #[ORM\Column(name'title'type'string'length191)]
  31.     private ?string $title null;
  32.     #[ORM\Column(name'content'typeTypes::TEXTnullabletrue)]
  33.     private ?string $content null;
  34.     #[ORM\ManyToMany(targetEntity"App\Entity\Company"inversedBy'pages'cascade: ['persist'], orphanRemovalfalse)]
  35.     #[ORM\JoinTable(name'pages_companies')]
  36.     #[ORM\JoinColumn(name'page_id'referencedColumnName'id'onDelete'CASCADE')]
  37.     #[ORM\InverseJoinColumn(name'company_id'referencedColumnName'id'onDelete'CASCADE')]
  38.     private Collection $companies;
  39.     #[ORM\Column(name'display_locations'typeTypes::JSONnullabletrue)]
  40.     private ?array $displayLocations = [];
  41.     public function __construct()
  42.     {
  43.         $this->companies = new ArrayCollection();
  44.     }
  45.     public function __toString()
  46.     {
  47.         return (string) ($this->title ?? $this->id);
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getTitle(): ?string
  54.     {
  55.         return $this->title;
  56.     }
  57.     public function setTitle(string $title): static
  58.     {
  59.         $this->title $title;
  60.         return $this;
  61.     }
  62.     public function getContent(): ?string
  63.     {
  64.         return $this->content;
  65.     }
  66.     public function setContent(?string $content): static
  67.     {
  68.         $this->content $content;
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return Collection<int, Company>
  73.      */
  74.     public function getCompanies(): Collection
  75.     {
  76.         return $this->companies;
  77.     }
  78.     public function addCompany(Company $company): static
  79.     {
  80.         if (!$this->companies->contains($company)) {
  81.             $this->companies->add($company);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeCompany(Company $company): static
  86.     {
  87.         $this->companies->removeElement($company);
  88.         return $this;
  89.     }
  90.     public function getDisplayLocations(): array
  91.     {
  92.         return $this->displayLocations ?? [];
  93.     }
  94.     public function setDisplayLocations(?array $displayLocations): static
  95.     {
  96.         $this->displayLocations $displayLocations ?? [];
  97.         return $this;
  98.     }
  99.     public function getSlug()
  100.     {
  101.         return $this->slug;
  102.     }
  103.     public function setSlug($slug): static
  104.     {
  105.         $this->slug $slug;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return \DateTime|null
  110.      */
  111.     public function getCreatedAt()
  112.     {
  113.         return $this->createdAt;
  114.     }
  115.     public function setCreatedAt($createdAt null): static
  116.     {
  117.         $this->createdAt $createdAt;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return \DateTime|null
  122.      */
  123.     public function getUpdatedAt()
  124.     {
  125.         return $this->updatedAt;
  126.     }
  127.     public function setUpdatedAt($updatedAt null): static
  128.     {
  129.         $this->updatedAt $updatedAt;
  130.         return $this;
  131.     }
  132.     public function getActive()
  133.     {
  134.         return $this->active;
  135.     }
  136.     public function setActive($active): static
  137.     {
  138.         $this->active $active;
  139.         return $this;
  140.     }
  141.     public function getActiveLabel(): string
  142.     {
  143.         return $this->active ActiveConstants::LABEL_YES ActiveConstants::LABEL_NO;
  144.     }
  145.     public function getMetaImage(): ?SonataMediaMedia
  146.     {
  147.         return $this->meta_image;
  148.     }
  149.     public function setMetaImage(?SonataMediaMedia $meta_image): static
  150.     {
  151.         $this->meta_image $meta_image;
  152.         return $this;
  153.     }
  154.     public function getMetaTitle()
  155.     {
  156.         return $this->metaTitle;
  157.     }
  158.     public function setMetaTitle($metaTitle): static
  159.     {
  160.         $this->metaTitle $metaTitle;
  161.         return $this;
  162.     }
  163.     public function getMetaDescription()
  164.     {
  165.         return $this->metaDescription;
  166.     }
  167.     public function setMetaDescription($metaDescription): static
  168.     {
  169.         $this->metaDescription $metaDescription;
  170.         return $this;
  171.     }
  172.     public function getMetaKeywords()
  173.     {
  174.         return $this->metaKeywords;
  175.     }
  176.     public function setMetaKeywords($metaKeywords): static
  177.     {
  178.         $this->metaKeywords $metaKeywords;
  179.         return $this;
  180.     }
  181.     public function getMetaCanonical()
  182.     {
  183.         return $this->metaCanonical;
  184.     }
  185.     public function setMetaCanonical($metaCanonical): static
  186.     {
  187.         $this->metaCanonical $metaCanonical;
  188.         return $this;
  189.     }
  190. }