src/Entity/ProductProducer.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use AppBundle\Entity\Article;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. use Symfony\Component\HttpFoundation\File\UploadedFile;
  15. use Symfony\Component\HttpFoundation\File\File;
  16. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  17. /**
  18.  * @ORM\Entity
  19.  * @ORM\Table(name="product_producer")
  20.  */
  21. class ProductProducer implements BlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  22.     use BlameableTrait;
  23.     use TimestampableTrait;
  24.     
  25.     use SoftDeletableTrait;
  26.     
  27. /**
  28.      * @ORM\Id
  29.      * @ORM\Column(type="integer")
  30.      * @ORM\GeneratedValue(strategy="AUTO")
  31.      */
  32.     protected $id;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  37.      */
  38.     private $name;
  39.     /**
  40.      * @var string
  41.      *
  42.      * @ORM\Column(name="responsible_entity", type="string", length=1024, nullable=true)
  43.      */
  44.     private $responsibleEntity;
  45.     /**
  46.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\Marker", mappedBy="productProducer", cascade={"persist"})
  47.      */
  48.     protected $markers;
  49.     /**
  50.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ListingMarker", mappedBy="productProducer", cascade={"persist"})
  51.      */
  52.     protected $listingMarkers;
  53.     /**
  54.      * Landing page do redirectu, gdy klikamy logo
  55.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\LandingPage")
  56.      * @Doctrine\ORM\Mapping\JoinTable(name="producer_landing_page",
  57.      *      joinColumns={@Doctrine\ORM\Mapping\JoinColumn(name="landing_page_id", referencedColumnName="id")},
  58.      *      inverseJoinColumns={@Doctrine\ORM\Mapping\JoinColumn(name="product_producer_id", referencedColumnName="id")}
  59.      *      )
  60.      **/
  61.     protected $redirectLadingPages;
  62.     /**
  63.      * Wersje językowe, gdzie logo ma być widoczne
  64.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Language")
  65.      * @Doctrine\ORM\Mapping\JoinTable(name="product_producer_languages",
  66.      *      joinColumns={@Doctrine\ORM\Mapping\JoinColumn(name="product_producer_id", referencedColumnName="id")},
  67.      *      inverseJoinColumns={@Doctrine\ORM\Mapping\JoinColumn(name="language_id", referencedColumnName="id")}
  68.      *      )
  69.      **/
  70.     protected $languages;
  71.     /**
  72.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductProducerPriceChange", mappedBy="productProducer", cascade={"persist"})
  73.      */
  74.     protected $priceChanges;
  75.     
  76.     /**
  77.      * Get id
  78.      *
  79.      * @return integer
  80.      */
  81.     public function getId()
  82.     {
  83.         return $this->id;
  84.     }
  85.     /**
  86.      * Set name
  87.      *
  88.      * @param string $name
  89.      *
  90.      * @return ProductProducer
  91.      */
  92.     public function setName($name)
  93.     {
  94.         $this->name $name;
  95.         return $this;
  96.     }
  97.     /**
  98.      * Get name
  99.      *
  100.      * @return string
  101.      */
  102.     public function getName()
  103.     {
  104.         return $this->name;
  105.     }
  106.     /**
  107.      *
  108.      * note This is not a mapped field of entity metadata, just a simple property.
  109.      *
  110.      * @var File $imageFile
  111.      */
  112.     protected $imageFile;
  113.     /**
  114.      * @ORM\Column(type="string", length=255, name="image_name", nullable=true)
  115.      * @var string $imageName
  116.      */
  117.     protected $imageName;
  118.     public function __construct()
  119.     {
  120.         $this->markers = new ArrayCollection();
  121.         $this->redirectLadingPages = new ArrayCollection();
  122.         $this->listingMarkers = new ArrayCollection();
  123.         $this->languages = new \Doctrine\Common\Collections\ArrayCollection();
  124.         $this->priceChanges = new ArrayCollection();
  125.     }
  126.     public function setImageFile(File $image null)
  127.     {
  128.         $this->imageFile $image;
  129.         if ($image) {
  130.             $fileName md5(uniqid()).'.'.$image->guessExtension();
  131.             // Move the file to the directory where brochures are stored
  132.             $brochuresDir getcwd().'/images/producer/';
  133.             $image->move($brochuresDir$fileName);
  134.             // Update the 'brochure' property to store the PDF file name
  135.             // instead of its contents
  136.             $this->setImageName($fileName);
  137.             $this->updatedAt = new \DateTime('now');
  138.         }
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return File
  143.      */
  144.     public function getImageFile()
  145.     {
  146.         return $this->imageFile;
  147.     }
  148.     /**
  149.      * @param string $imageName
  150.      */
  151.     public function setImageName($imageName)
  152.     {
  153.         $this->imageName $imageName;
  154.     }
  155.     /**
  156.      * @return string
  157.      */
  158.     public function getImageName()
  159.     {
  160.         return $this->imageName;
  161.     }
  162.     /**
  163.      * @return Collection|Marker[]
  164.      */
  165.     public function getMarkers(): Collection
  166.     {
  167.         return $this->markers;
  168.     }
  169.     public function addMarker(Marker $marker): self
  170.     {
  171.         if (!$this->markers->contains($marker)) {
  172.             $this->markers[] = $marker;
  173.             $marker->setProductProducer($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeMarker(Marker $marker): self
  178.     {
  179.         if ($this->markers->contains($marker)) {
  180.             $this->markers->removeElement($marker);
  181.             // set the owning side to null (unless already changed)
  182.             if ($marker->getProductProducer() === $this) {
  183.                 $marker->setProductProducer(null);
  184.             }
  185.         }
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return Collection|LandingPage[]
  190.      */
  191.     public function getRedirectLadingPages(): Collection
  192.     {
  193.         return $this->redirectLadingPages;
  194.     }
  195.     public function addRedirectLadingPage(LandingPage $redirectLadingPage): self
  196.     {
  197.         if (!$this->redirectLadingPages->contains($redirectLadingPage)) {
  198.             $this->redirectLadingPages[] = $redirectLadingPage;
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeRedirectLadingPage(LandingPage $redirectLadingPage): self
  203.     {
  204.         if ($this->redirectLadingPages->contains($redirectLadingPage)) {
  205.             $this->redirectLadingPages->removeElement($redirectLadingPage);
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection|ListingMarker[]
  211.      */
  212.     public function getListingMarkers(): Collection
  213.     {
  214.         return $this->listingMarkers;
  215.     }
  216.     public function addListingMarker(ListingMarker $listingMarker): self
  217.     {
  218.         if (!$this->listingMarkers->contains($listingMarker)) {
  219.             $this->listingMarkers[] = $listingMarker;
  220.             $listingMarker->setProductProducer($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeListingMarker(ListingMarker $listingMarker): self
  225.     {
  226.         if ($this->listingMarkers->contains($listingMarker)) {
  227.             $this->listingMarkers->removeElement($listingMarker);
  228.             // set the owning side to null (unless already changed)
  229.             if ($listingMarker->getProductProducer() === $this) {
  230.                 $listingMarker->setProductProducer(null);
  231.             }
  232.         }
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection|ProductProducerPriceChange[]
  237.      */
  238.     public function getPriceChanges(): Collection
  239.     {
  240.         return $this->priceChanges;
  241.     }
  242.     public function addPriceChange(ProductProducerPriceChange $priceChange): self
  243.     {
  244.         if (!$this->priceChanges->contains($priceChange)) {
  245.             $this->priceChanges[] = $priceChange;
  246.             $priceChange->setProductProducer($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removePriceChange(ProductProducerPriceChange $priceChange): self
  251.     {
  252.         if ($this->priceChanges->removeElement($priceChange)) {
  253.             // set the owning side to null (unless already changed)
  254.             if ($priceChange->getProductProducer() === $this) {
  255.                 $priceChange->setProductProducer(null);
  256.             }
  257.         }
  258.         return $this;
  259.     }
  260.     /**
  261.      * Add language
  262.      *
  263.      * @param \App\Entity\Language $language
  264.      *
  265.      * @return ProductProducer
  266.      */
  267.     public function addLanguage(\App\Entity\Language $language)
  268.     {
  269.         $this->languages[] = $language;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Remove language
  274.      *
  275.      * @param \App\Entity\Language $language
  276.      */
  277.     public function removeLanguage(\App\Entity\Language $language)
  278.     {
  279.         $this->languages->removeElement($language);
  280.     }
  281.     /**
  282.      * Get languages
  283.      *
  284.      * @return \Doctrine\Common\Collections\Collection
  285.      */
  286.     public function getLanguages()
  287.     {
  288.         return $this->languages;
  289.     }
  290.     /**
  291.      * @return string
  292.      */
  293.     public function getResponsibleEntity()
  294.     {
  295.         return $this->responsibleEntity;
  296.     }
  297.     /**
  298.      * @param string $responsibleEntity
  299.      */
  300.     public function setResponsibleEntity($responsibleEntity)
  301.     {
  302.         $this->responsibleEntity $responsibleEntity;
  303.     }
  304. }