src/Entity/Otpusk/Geo/BaseObject.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Otpusk\Geo;
  3. use App\Repository\Otpusk\Geo\BaseObjectRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=BaseObjectRepository::class)
  7.  * @ORM\Table("tGeo")
  8.  * @ORM\InheritanceType("JOINED")
  9.  * @ORM\DiscriminatorColumn(name="type", type="string")
  10.  * @ORM\DiscriminatorMap({
  11.  *     "base" = "\App\Entity\Otpusk\Geo\BaseObject",
  12.  *     "district" = "\App\Entity\Otpusk\Geo\District",
  13.  *     "province" = "\App\Entity\Otpusk\Geo\Province",
  14.  *     "country" = "\App\Entity\Otpusk\Country",
  15.  *     "city" = "\App\Entity\Otpusk\City",
  16.  *     "hotel" = "\App\Entity\Otpusk\Hotel"
  17.  * })
  18.  */
  19. class BaseObject
  20. {
  21.     const LABEL_DISTRICT 'район города';
  22.     const LABEL_PROVINCE 'регион страны';
  23.     const LABEL_COUNTRY 'страна';
  24.     const LABEL_CITY 'город';
  25.     const LABEL_HOTEL 'отель';
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(name="rec_id", type="integer", length=10, options={"unsigned"=true})
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity=BaseObject::class, inversedBy="geos")
  34.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="rec_id", nullable=true)
  35.      */
  36.     private $parent;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=BaseObject::class, mappedBy="parent")
  39.      */
  40.     private $geos;
  41.     /**
  42.      * @return mixed
  43.      */
  44.     public function getId()
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getParent(): ?self
  49.     {
  50.         return $this->parent;
  51.     }
  52.     public function setParent(?self $parent): self
  53.     {
  54.         $this->parent $parent;
  55.         return $this;
  56.     }
  57.     public function getParentsPath()
  58.     {
  59.         $path = [];
  60.         $parent $this->getParent();
  61.         do {
  62.             if ($parent) {
  63.                 $path[] = $parent->getName();
  64.                 $parent $parent->getParent();
  65.             }
  66.         } while ($parent);
  67.         return join(', '$path);
  68.     }
  69.     public function getGeos() {
  70.         return $this->geos;
  71.     }
  72.     public function getTypeLabel(): string
  73.     {
  74.         return '';
  75.     }
  76. }