<?php
namespace App\Entity\Otpusk;
use App\Repository\Otpusk\GeoBlockRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=GeoBlockRepository::class)
* @Vich\Uploadable()
*/
class GeoBlock implements TranslatableInterface
{
use TimestampableEntity;
use TranslatableTrait;
private $imgFolder = '/upload/';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=1024)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Vich\UploadableField(mapping="images", fileNameProperty="image")
*/
private $imageFile;
/**
* @ORM\Column(type="boolean")
*/
private $published;
/**
* @var integer
* @Gedmo\SortablePosition
* @ORM\Column(name="priority", type="integer", options={"default":0}, nullable=true)
*/
private $position = 0;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Country", inversedBy="geoBlocks")
* @ORM\JoinColumn(name="country_id", referencedColumnName="rec_id", nullable=true)
*/
private $country;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\City", inversedBy="geoBlocks")
* @ORM\JoinColumn(name="city_id", referencedColumnName="rec_id", nullable=true)
*/
private $city;
/**
* @ORM\Column(name="type", type="geoBlockType", options={"default":"about"}, nullable=false)
*/
private $type;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return mixed
*/
public function getImage()
{
return $this->image;
}
/**
* @param mixed $image
*/
public function setImage($image): void
{
$this->image = $image;
}
/**
* @return mixed
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param mixed $imageFile
*/
public function setImageFile($imageFile = null): void
{
$this->imageFile = $imageFile;
if ($imageFile) {
$this->updatedAt = new \DateTime();
}
}
public function getPublished(): ?bool
{
return $this->published;
}
public function setPublished(bool $published): self
{
$this->published = $published;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = (!is_null($position))?$position:0;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getType()
{
return $this->type;
}
public function setType($type): self
{
$this->type = $type;
return $this;
}
public function getTypes(): array
{
return [
'О гео' => 'about',
'Интересные факты' => 'facts',
'Чартери' => 'charters',
];
}
public function __toString()
{
return $this->getName();
}
public function getLinkImage(): string
{
return (!is_null($this->getImage())) ? $this->imgFolder.$this->getImage() : '#';
}
}