<?php
namespace App\Entity\Otpusk\Geo;
use App\Repository\Otpusk\Geo\BaseObjectRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=BaseObjectRepository::class)
* @ORM\Table("tGeo")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({
* "base" = "\App\Entity\Otpusk\Geo\BaseObject",
* "district" = "\App\Entity\Otpusk\Geo\District",
* "province" = "\App\Entity\Otpusk\Geo\Province",
* "country" = "\App\Entity\Otpusk\Country",
* "city" = "\App\Entity\Otpusk\City",
* "hotel" = "\App\Entity\Otpusk\Hotel"
* })
*/
class BaseObject
{
const LABEL_DISTRICT = 'район города';
const LABEL_PROVINCE = 'регион страны';
const LABEL_COUNTRY = 'страна';
const LABEL_CITY = 'город';
const LABEL_HOTEL = 'отель';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="rec_id", type="integer", length=10, options={"unsigned"=true})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=BaseObject::class, inversedBy="geos")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="rec_id", nullable=true)
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity=BaseObject::class, mappedBy="parent")
*/
private $geos;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
public function getParentsPath()
{
$path = [];
$parent = $this->getParent();
do {
if ($parent) {
$path[] = $parent->getName();
$parent = $parent->getParent();
}
} while ($parent);
return join(', ', $path);
}
public function getGeos() {
return $this->geos;
}
public function getTypeLabel(): string
{
return '';
}
}