src/Entity/HearingBrand.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Stat\Report;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass="App\Repository\HearingBrandRepository")
  14.  * @Vich\Uploadable
  15.  */
  16. class HearingBrand
  17. {
  18.     /**
  19.      * @ORM\Id()
  20.      * @ORM\GeneratedValue()
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $name;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $type "big_brand";
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      * @Gedmo\Slug(fields={"name"})
  35.      */
  36.     private $slug;
  37.     /**
  38.      * @ORM\Column(type="string", length=255)
  39.      */
  40.     private $logoPath;
  41.     /**
  42.      * @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg"})
  43.      * @Vich\UploadableField(mapping="brand_logo", fileNameProperty="logoPath")
  44.      * @var File
  45.      */
  46.     private $logoFile;
  47.     /**
  48.      * @Vich\UploadableField(mapping="brand_logo", fileNameProperty="logoVariationPath")
  49.      * @var File
  50.      */
  51.     private $logoVariationFile;
  52.     /**
  53.      * @ORM\Column(type="string", length=255)
  54.      */
  55.     private $logoVariationPath;
  56.     /**
  57.      * @ORM\Column(type="datetime", nullable=true)
  58.      * @var DateTime
  59.      */
  60.     private $updatedAt;
  61.     /**
  62.      * @ORM\Column(type="string", length=255, nullable=true)
  63.      */
  64.     private $phoneNumber;
  65.     /**
  66.      * @ORM\Column(type="string", length=255, nullable=true)
  67.      */
  68.     private $address;
  69.     /**
  70.      * @ORM\Column(type="string", length=255, nullable=true)
  71.      */
  72.     private $openingHours;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity="App\Entity\Store", mappedBy="hearingBrand")
  75.      */
  76.     private $stores;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\Stat\Report", mappedBy="brand")
  79.      */
  80.     private $reports;
  81.     /**
  82.      * @ORM\Column(type="boolean")
  83.      */
  84.     private $presentable 0// Logo présentable
  85.     /**
  86.      * @ORM\Column(type="text", nullable=true)
  87.      */
  88.     private $wording;
  89.     /**
  90.      * indexable in file sitemap.xml
  91.      * @ORM\Column(type="boolean")
  92.      * @var boolean
  93.      */
  94.     private $indexable true;
  95.     public function __construct()
  96.     {
  97.         $this->stores = new ArrayCollection();
  98.         $this->reports = new ArrayCollection();
  99.     }
  100.     /**
  101.      * Représente l'entité par défault
  102.      * @return string
  103.      */
  104.     public function __toString(){
  105.         return 'HearingBrand '.$this->getName().' ['.$this->getId().']';
  106.     }
  107.     /**
  108.      * Représente l'entité dans le BO
  109.      * @return string
  110.      */
  111.     public function getLabel(){
  112.         return $this->getName();
  113.     }
  114.     public function getId(): ?int
  115.     {
  116.         return $this->id;
  117.     }
  118.     public function getName(): ?string
  119.     {
  120.         return $this->name;
  121.     }
  122.     public function setName(string $name): self
  123.     {
  124.         $this->name $name;
  125.         return $this;
  126.     }
  127.     public function getType(): ?string
  128.     {
  129.         return $this->type;
  130.     }
  131.     public function setType(string $type): self
  132.     {
  133.         $this->type $type;
  134.         return $this;
  135.     }
  136.     /**
  137.      * @return Collection|HearingBrand[]
  138.      */
  139.     public function getStores(): Collection
  140.     {
  141.         return $this->stores;
  142.     }
  143.     public function addStore(HearingBrand $store): self
  144.     {
  145.         if (!$this->stores->contains($store)) {
  146.             $this->stores[] = $store;
  147.             $store->setStore($this);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeStore(HearingBrand $store): self
  152.     {
  153.         if ($this->stores->contains($store)) {
  154.             $this->stores->removeElement($store);
  155.             // set the owning side to null (unless already changed)
  156.             if ($store->getStore() === $this) {
  157.                 $store->setStore(null);
  158.             }
  159.         }
  160.         return $this;
  161.     }
  162.     public function getSlug(): ?string
  163.     {
  164.         return $this->slug;
  165.     }
  166.     public function setSlug(string $slug): self
  167.     {
  168.         $this->slug $slug;
  169.         return $this;
  170.     }
  171.     public function getPhoneNumber(): ?string
  172.     {
  173.         return $this->phoneNumber;
  174.     }
  175.     public function setPhoneNumber(?string $phoneNumber): self
  176.     {
  177.         $this->phoneNumber $phoneNumber;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return mixed
  182.      */
  183.     public function getReports()
  184.     {
  185.         return $this->reports;
  186.     }
  187.     /**
  188.      * @param mixed $reports
  189.      */
  190.     public function setReports($reports): void
  191.     {
  192.         $this->reports $reports;
  193.     }
  194.     public function getPresentable(): ?bool
  195.     {
  196.         return $this->presentable;
  197.     }
  198.     public function setPresentable(bool $presentable): self
  199.     {
  200.         $this->presentable $presentable;
  201.         return $this;
  202.     }
  203.     public function getAddress(): ?string
  204.     {
  205.         return $this->address;
  206.     }
  207.     public function setAddress(?string $address): self
  208.     {
  209.         $this->address $address;
  210.         return $this;
  211.     }
  212.     public function addReport(Report $report): self
  213.     {
  214.         if (!$this->reports->contains($report)) {
  215.             $this->reports[] = $report;
  216.             $report->setBrand($this);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeReport(Report $report): self
  221.     {
  222.         if ($this->reports->contains($report)) {
  223.             $this->reports->removeElement($report);
  224.             // set the owning side to null (unless already changed)
  225.             if ($report->getBrand() === $this) {
  226.                 $report->setBrand(null);
  227.             }
  228.         }
  229.         return $this;
  230.     }
  231.     public function getOpeningHours(): ?string
  232.     {
  233.         return $this->openingHours;
  234.     }
  235.     public function setOpeningHours(?string $openingHours): self
  236.     {
  237.         $this->openingHours $openingHours;
  238.         return $this;
  239.     }
  240.     public function getLogoPath(): ?string
  241.     {
  242.         return $this->logoPath;
  243.     }
  244.     public function setLogoPath(string $logoPath=null): self
  245.     {
  246.         $this->logoPath $logoPath;
  247.         return $this;
  248.     }
  249.     public function hasLogo(){
  250.         return !is_null($this->logoPath);
  251.     }
  252.     public function setLogoFile(File $image null)
  253.     {
  254.         $this->logoFile $image;
  255.         //update timestamp
  256.         if ($image) {
  257.             $this->updatedAt = new DateTime('now');
  258.         }
  259.     }
  260.     public function getLogoFile()
  261.     {
  262.         return $this->logoFile;
  263.     }
  264.     public function getLogoVariationPath(): ?string
  265.     {
  266.         return $this->logoVariationPath;
  267.     }
  268.     public function setLogoVariationPath(string $logoVariationPath=null): self
  269.     {
  270.         $this->logoVariationPath $logoVariationPath;
  271.         return $this;
  272.     }
  273.     public function setLogoVariationFile(File $image null)
  274.     {
  275.         $this->logoVariationFile $image;
  276.         //update timestamp
  277.         if ($image) {
  278.             $this->updatedAt = new DateTime('now');
  279.         }
  280.     }
  281.     public function getLogoVariationFile()
  282.     {
  283.         return $this->logoVariationFile;
  284.     }
  285.     public function getUpdatedAt(): ?\DateTimeInterface
  286.     {
  287.         return $this->updatedAt;
  288.     }
  289.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  290.     {
  291.         $this->updatedAt $updatedAt;
  292.         return $this;
  293.     }
  294.     public function isUpdated():bool
  295.     {
  296.         if($this->updatedAt !== NULL) {
  297.             if (date_diff($this->updatedAt, new \DateTime('now'))->days 31) {
  298.                 return true;
  299.             }
  300.         }
  301.         return false;
  302.     }
  303.     public function getWording(): ?string
  304.     {
  305.         return $this->wording;
  306.     }
  307.     public function setWording(?string $wording): self
  308.     {
  309.         $this->wording $wording;
  310.         return $this;
  311.     }
  312.     public function getIndexable(): ?bool
  313.     {
  314.         return $this->indexable;
  315.     }
  316.     public function setIndexable(bool $indexable): self
  317.     {
  318.         $this->indexable $indexable;
  319.         return $this;
  320.     }
  321. }