src/Entity/Otpusk/Rubric.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Otpusk;
  3. use App\Entity\Stock\Stock;
  4. use App\Repository\Otpusk\RubricRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  10. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. /**
  14.  * @ORM\Entity(repositoryClass=RubricRepository::class)
  15.  * @Vich\Uploadable()
  16.  */
  17. class Rubric implements TranslatableInterface
  18. {
  19.     use TimestampableEntity;
  20.     use TranslatableTrait;
  21.     private $imgFolder '/upload/rubric/';
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=1024)
  30.      */
  31.     private $name;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $slug;
  36.     /**
  37.      * @ORM\Column(type="string", length=255, nullable=true)
  38.      */
  39.     private $image;
  40.     /**
  41.      * @Vich\UploadableField(mapping="rubric", fileNameProperty="image")
  42.      */
  43.     private $imageFile;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity="App\Entity\Otpusk\RubricCity", mappedBy="rubric", cascade={"persist"}, orphanRemoval=true)
  46.      */
  47.     private $cities;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity="App\Entity\Otpusk\RubricCountry", mappedBy="rubric", cascade={"persist"}, orphanRemoval=true)
  50.      */
  51.     private $countries;
  52.     private $citiesOutput;
  53.     public function __construct()
  54.     {
  55.         $this->countries = new ArrayCollection();
  56.         $this->cities = new ArrayCollection();
  57.         $this->updatedAt = new \DateTime();
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getName(): ?string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function setName(string $name): self
  68.     {
  69.         $this->name $name;
  70.         return $this;
  71.     }
  72.     public function getSlug(): ?string
  73.     {
  74.         return $this->slug;
  75.     }
  76.     public function setSlug(string $slug): self
  77.     {
  78.         $this->slug $slug;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return mixed
  83.      */
  84.     public function getImage()
  85.     {
  86.         return $this->image;
  87.     }
  88.     /**
  89.      * @param mixed $image
  90.      */
  91.     public function setImage($image): void
  92.     {
  93.         $this->image $image;
  94.     }
  95.     public function getLinkImage()
  96.     {
  97.         return (!is_null($this->getImage())) ? $this->imgFolder.$this->getImage() : '#';
  98.     }
  99.     /**
  100.      * @return mixed
  101.      */
  102.     public function getImageFile()
  103.     {
  104.         return $this->imageFile;
  105.     }
  106.     /**
  107.      * @param mixed $imageFile
  108.      */
  109.     public function setImageFile($imageFile null): void
  110.     {
  111.         $this->imageFile $imageFile;
  112.         if ($imageFile) {
  113.             $this->updatedAt = new \DateTime();
  114.         }
  115.     }
  116.     public function __toString()
  117.     {
  118.         return $this->getName();
  119.     }
  120.     /**
  121.      * @return Collection|RubricCity[]
  122.      */
  123.     public function getCities(): Collection
  124.     {
  125.         return $this->cities;
  126.     }
  127.     public function addCity(RubricCity $city): self
  128.     {
  129.         if (!$this->cities->contains($city)) {
  130.             $this->cities[] = $city;
  131.             $city->setRubric($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeCity(RubricCity $city): self
  136.     {
  137.         if ($this->cities->contains($city)) {
  138.             $this->cities->removeElement($city);
  139.             if ($city->getRubric() === $this) {
  140.                 $city->setRubric(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection|RubricCountry[]
  147.      */
  148.     public function getCountries(): Collection
  149.     {
  150.         return $this->countries;
  151.     }
  152.     public function addCountry(RubricCountry $country): self
  153.     {
  154.         if (!$this->countries->contains($country)) {
  155.             $this->countries[] = $country;
  156.             $country->setRubric($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeCountry(RubricCountry $country): self
  161.     {
  162.         if ($this->countries->contains($country)) {
  163.             $this->countries->removeElement($country);
  164.             if ($country->getRubric() === $this) {
  165.                 $country->setRubric(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     public function getCitiesOutput()
  171.     {
  172.         return $this->citiesOutput;
  173.     }
  174.     public function setCitiesOutput($citiesOutput): void
  175.     {
  176.         $this->citiesOutput $citiesOutput;
  177.     }
  178. }