src/Entity/Service.php line 29

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