src/Entity/Sector.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\LinkTrait;
  4. use App\Entity\Traits\MetaTrait;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Traits\ActiveTrait;
  7. use App\Entity\Traits\DeleteTrait;
  8. use App\Repository\SectorRepository;
  9. use App\Entity\Traits\SortOrderTrait;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. // use App\Entity\Traits\TranslateTrait;
  12. use App\Entity\Traits\ImageUploadTrait;
  13. use App\Entity\Traits\SecondContentTrait;
  14. use Doctrine\Common\Collections\Criteria;
  15. use App\Entity\Traits\TitleAndContentTrait;
  16. use Doctrine\Common\Collections\Collection;
  17. use App\Entity\Traits\ThirdImageUploadTrait;
  18. use App\Entity\Traits\SecondImageUploadTrait;
  19. use App\Entity\Interfaces\DefaultLinkedEntity;
  20. use App\Entity\Traits\FeaturedTrait;
  21. use Doctrine\Common\Collections\ArrayCollection;
  22. use Gedmo\Timestampable\Traits\TimestampableEntity;
  23. /**
  24.  * @Gedmo\Loggable
  25.  */
  26. #[ORM\Entity(repositoryClassSectorRepository::class)]
  27. class Sector implements DefaultLinkedEntity
  28. {
  29.     use TitleAndContentTrait;
  30.     use SecondContentTrait;
  31.     use LinkTrait;
  32.     use ImageUploadTrait;
  33.     use SecondImageUploadTrait;
  34.     use MetaTrait;
  35.     use SortOrderTrait;
  36.     use ActiveTrait;
  37.     use DeleteTrait;
  38.     use TimestampableEntity;
  39.     use FeaturedTrait;
  40.     #[ORM\Id]
  41.     #[ORM\GeneratedValue]
  42.     #[ORM\Column(type:"integer")]
  43.     private $id;
  44.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'children')]
  45.     private $parent;
  46.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class)]
  47.     private $children;
  48.     #[ORM\Column(type'string'length255nullabletrue)]
  49.     private $iconClass;
  50.     #[ORM\Column(type'text'nullabletrue)]
  51.     private $excerpt;
  52.     public function __construct()
  53.     {
  54.         $this->children = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getLinkedPageId(): int
  61.     {
  62.         return 17;
  63.     }
  64.     public function getParent(): ?self
  65.     {
  66.         return $this->parent;
  67.     }
  68.     public function setParent(?self $parent): self
  69.     {
  70.         $this->parent $parent;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, self>
  75.      */
  76.     public function getChildren(): Collection
  77.     {
  78.         return $this->children;
  79.     }
  80.     public function addChild(self $child): self
  81.     {
  82.         if (!$this->children->contains($child)) {
  83.             $this->children[] = $child;
  84.             $child->setParent($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeChild(self $child): self
  89.     {
  90.         if ($this->children->removeElement($child)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($child->getParent() === $this) {
  93.                 $child->setParent(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     public function getActiveChildren(): Collection
  99.     {
  100.         $criteria Criteria::create()
  101.             ->andWhere(Criteria::expr()->eq('active'true))
  102.             ->andWhere(Criteria::expr()->eq('deleted'false));
  103.         return $this->children->matching($criteria);
  104.     }
  105.     public function getIconClass(): ?string
  106.     {
  107.         return $this->iconClass;
  108.     }
  109.     public function setIconClass(?string $iconClass): self
  110.     {
  111.         $this->iconClass $iconClass;
  112.         return $this;
  113.     }
  114.     public function getExcerpt(): ?string
  115.     {
  116.         return $this->excerpt;
  117.     }
  118.     public function setExcerpt(?string $excerpt): self
  119.     {
  120.         $this->excerpt $excerpt;
  121.         return $this;
  122.     }
  123. }