src/Entity/Otpusk/GeoBlock.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Otpusk;
  3. use App\Repository\Otpusk\GeoBlockRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Timestampable\Traits\TimestampableEntity;
  6. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  7. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. /**
  11.  * @ORM\Entity(repositoryClass=GeoBlockRepository::class)
  12.  * @Vich\Uploadable()
  13.  */
  14. class GeoBlock implements TranslatableInterface
  15. {
  16.     use TimestampableEntity;
  17.     use TranslatableTrait;
  18.     private $imgFolder '/upload/';
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=1024)
  27.      */
  28.     private $name;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable=true)
  31.      */
  32.     private $image;
  33.     /**
  34.      * @Vich\UploadableField(mapping="images", fileNameProperty="image")
  35.      */
  36.     private $imageFile;
  37.     /**
  38.      * @ORM\Column(type="boolean")
  39.      */
  40.     private $published;
  41.     /**
  42.      * @var integer
  43.      * @Gedmo\SortablePosition
  44.      * @ORM\Column(name="priority", type="integer", options={"default":0}, nullable=true)
  45.      */
  46.     private $position 0;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Country", inversedBy="geoBlocks")
  49.      * @ORM\JoinColumn(name="country_id", referencedColumnName="rec_id", nullable=true)
  50.      */
  51.     private $country;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\City", inversedBy="geoBlocks")
  54.      * @ORM\JoinColumn(name="city_id", referencedColumnName="rec_id", nullable=true)
  55.      */
  56.     private $city;
  57.     /**
  58.      * @ORM\Column(name="type", type="geoBlockType", options={"default":"about"}, nullable=false)
  59.      */
  60.     private $type;
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getName(): ?string
  66.     {
  67.         return $this->name;
  68.     }
  69.     public function setName(string $name): self
  70.     {
  71.         $this->name $name;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return mixed
  76.      */
  77.     public function getImage()
  78.     {
  79.         return $this->image;
  80.     }
  81.     /**
  82.      * @param mixed $image
  83.      */
  84.     public function setImage($image): void
  85.     {
  86.         $this->image $image;
  87.     }
  88.     /**
  89.      * @return mixed
  90.      */
  91.     public function getImageFile()
  92.     {
  93.         return $this->imageFile;
  94.     }
  95.     /**
  96.      * @param mixed $imageFile
  97.      */
  98.     public function setImageFile($imageFile null): void
  99.     {
  100.         $this->imageFile $imageFile;
  101.         if ($imageFile) {
  102.             $this->updatedAt = new \DateTime();
  103.         }
  104.     }
  105.     public function getPublished(): ?bool
  106.     {
  107.         return $this->published;
  108.     }
  109.     public function setPublished(bool $published): self
  110.     {
  111.         $this->published $published;
  112.         return $this;
  113.     }
  114.     public function getPosition(): ?int
  115.     {
  116.         return $this->position;
  117.     }
  118.     public function setPosition(?int $position): self
  119.     {
  120.         $this->position = (!is_null($position))?$position:0;
  121.         return $this;
  122.     }
  123.     public function getCountry(): ?Country
  124.     {
  125.         return $this->country;
  126.     }
  127.     public function setCountry(?Country $country): self
  128.     {
  129.         $this->country $country;
  130.         return $this;
  131.     }
  132.     public function getCity(): ?City
  133.     {
  134.         return $this->city;
  135.     }
  136.     public function setCity(?City $city): self
  137.     {
  138.         $this->city $city;
  139.         return $this;
  140.     }
  141.     public function getType()
  142.     {
  143.         return $this->type;
  144.     }
  145.     public function setType($type): self
  146.     {
  147.         $this->type $type;
  148.         return $this;
  149.     }
  150.     public function getTypes(): array
  151.     {
  152.         return [
  153.             'О гео' => 'about',
  154.             'Интересные факты' => 'facts',
  155.             'Чартери' => 'charters',
  156.         ];
  157.     }
  158.     public function __toString()
  159.     {
  160.         return $this->getName();
  161.     }
  162.     public function getLinkImage(): string
  163.     {
  164.         return (!is_null($this->getImage())) ? $this->imgFolder.$this->getImage() : '#';
  165.     }
  166. }