src/Entity/Product.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\SonataClassificationCategory;
  4. use App\Entity\SonataClassificationTag;
  5. use App\Application\Sonata\MediaBundle\Entity\Media;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * Product
  13.  *
  14.  * @ORM\Table(name="product")
  15.  * @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
  16.  */
  17. class Product
  18. {
  19.     use \Gedmo\Timestampable\Traits\TimestampableEntity;
  20.     use BlameableEntity;
  21.     /**
  22.      * @var int
  23.      *
  24.      * @ORM\Column(name="id", type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $id;
  29.     /**
  30.      * Title
  31.      * @ORM\Column(name="title", type="string", length=100)
  32.      */
  33.     private $title "";
  34.     /**
  35.      * Tagline
  36.      * @Assert\Length(max=140)
  37.      * @ORM\Column(name="tagline", type="string", length=140, nullable=true)
  38.      */
  39.     private $tagline;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity="App\Entity\ProductDeclinaison", mappedBy="product", cascade={"persist","remove"}, orphanRemoval=true)
  42.      * @ORM\OrderBy({"position" = "ASC"})
  43.      */
  44.     private $declinaison;
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"})
  47.      */
  48.     private $imageCaption;
  49.     /**
  50.      * @var string
  51.      * @ORM\Column(name="photo_credit",type="string", length=255, nullable=true)
  52.      */
  53.     private $photoCredit;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"})
  56.      */
  57.     private $banner;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity="App\Entity\SonataClassificationCategory", cascade={"persist"})
  60.      */
  61.     private $category;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity="App\Entity\SonataClassificationCategory", cascade={"persist"})
  64.      */
  65.     private $eventMainCategory;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity="App\Entity\SonataClassificationCategory", cascade={"persist"})
  68.      */
  69.     private $eventCategory;
  70.     /**
  71.      * @Gedmo\Slug(fields={"title"})
  72.      * @ORM\Column(length=128, unique=true)
  73.      */
  74.     private $slug;
  75.     /**
  76.      * Intro
  77.      * @ORM\Column(name="intro", type="text", nullable=true)
  78.      */
  79.     private $intro;
  80.     /**
  81.      * Description
  82.      * @ORM\Column(name="description", type="text", nullable=true)
  83.      */
  84.     private $description;
  85.     /**
  86.      * @var ArrayCollection $keyBenefits
  87.      * @ORM\OneToMany(targetEntity="App\Entity\KeyBenefit", mappedBy="product",cascade={"persist"}, orphanRemoval=true)
  88.      * @ORM\OrderBy({"position" = "ASC"})
  89.      */
  90.     private $keyBenefits;
  91.     /**
  92.      * @var boolean
  93.      * @ORM\Column(name="publish", type="boolean")
  94.      */
  95.     private $publish false;
  96.     /**
  97.      * @ORM\ManyToMany(targetEntity="App\Entity\SonataClassificationTag")
  98.      */
  99.     private $tags;
  100.     /**
  101.      * @ORM\ManyToMany(targetEntity="App\Entity\SonataClassificationTag")
  102.      * @ORM\JoinTable(
  103.      *     name="product_insight_tag",
  104.      *     joinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id")},
  105.      *     inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")}
  106.      * )
  107.      */
  108.     private $insightTags;
  109.     /**
  110.      * @Gedmo\SortablePosition
  111.      * @ORM\Column(name="position", type="integer", nullable=false)
  112.      */
  113.     private $position;
  114.     public function __construct()
  115.     {
  116.         $this->keyBenefits = new ArrayCollection();
  117.         $this->tags = new ArrayCollection();
  118.         $this->declinaison = new ArrayCollection();
  119.     }
  120.     /**
  121.      * @return mixed
  122.      */
  123.     public function getEventMainCategory()
  124.     {
  125.         return $this->eventMainCategory;
  126.     }
  127.     /**
  128.      * @param mixed $eventMainCategory
  129.      */
  130.     public function setEventMainCategory($eventMainCategory): void
  131.     {
  132.         $this->eventMainCategory $eventMainCategory;
  133.     }
  134.     /**
  135.      * @return mixed
  136.      */
  137.     public function getEventCategory()
  138.     {
  139.         return $this->eventCategory;
  140.     }
  141.     /**
  142.      * @param mixed $eventCategory
  143.      */
  144.     public function setEventCategory($eventCategory): void
  145.     {
  146.         $this->eventCategory $eventCategory;
  147.     }
  148.     /**
  149.      * @return mixed
  150.      */
  151.     public function getInsightTags()
  152.     {
  153.         return $this->insightTags;
  154.     }
  155.     /**
  156.      * @param mixed $insightTags
  157.      */
  158.     public function setInsightTags($insightTags): void
  159.     {
  160.         $this->insightTags $insightTags;
  161.     }
  162.     /**
  163.      * @return string
  164.      */
  165.     public function getPhotoCredit(): ?string
  166.     {
  167.         return $this->photoCredit;
  168.     }
  169.     /**
  170.      * @param string $photoCredit
  171.      */
  172.     public function setPhotoCredit(string $photoCredit null): void
  173.     {
  174.         $this->photoCredit $photoCredit;
  175.     }
  176.     public function __toString()
  177.     {
  178.         return $this->getTitle();
  179.     }
  180.     /**
  181.      * Get title
  182.      *
  183.      * @return string
  184.      */
  185.     public function getTitle()
  186.     {
  187.         return $this->title;
  188.     }
  189.     /**
  190.      * Set title
  191.      *
  192.      * @param string $title
  193.      *
  194.      * @return Product
  195.      */
  196.     public function setTitle($title)
  197.     {
  198.         $this->title $title;
  199.         return $this;
  200.     }
  201.     /**
  202.      * Add tag
  203.      *
  204.      * @param SonataClassificationTag $tag
  205.      *
  206.      * @return Product
  207.      */
  208.     public function addTag(SonataClassificationTag $tag)
  209.     {
  210.         $this->tags[] = $tag;
  211.         return $this;
  212.     }
  213.     /**
  214.      * Remove tag
  215.      *
  216.      * @param SonataClassificationTag $tag
  217.      */
  218.     public function removeTag(SonataClassificationTag $tag)
  219.     {
  220.         $this->tags->removeElement($tag);
  221.     }
  222.     /**
  223.      * Get tags
  224.      *
  225.      * @return Collection
  226.      */
  227.     public function getTags()
  228.     {
  229.         return $this->tags;
  230.     }
  231.     /**
  232.      * Get id
  233.      *
  234.      * @return integer
  235.      */
  236.     public function getId()
  237.     {
  238.         return $this->id;
  239.     }
  240.     public function toString(): string
  241.     {
  242.         return "{id=" $this->id "}";
  243.     }
  244.     /**
  245.      * @return string
  246.      */
  247.     public function getTagline()
  248.     {
  249.         return $this->tagline;
  250.     }
  251.     /**
  252.      * @param string $tagline
  253.      */
  254.     public function setTagline($tagline)
  255.     {
  256.         $this->tagline $tagline;
  257.     }
  258.     /**
  259.      * @return string
  260.      */
  261.     public function getBanner()
  262.     {
  263.         return $this->banner;
  264.     }
  265.     /**
  266.      * @param Media $banner
  267.      * @return Product
  268.      */
  269.     public function setBanner(Media $banner null)
  270.     {
  271.         $this->banner $banner;
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return mixed
  276.      */
  277.     public function getImageCaption()
  278.     {
  279.         return $this->imageCaption;
  280.     }
  281.     /**
  282.      * @param mixed $imageCaption
  283.      */
  284.     public function setImageCaption($imageCaption): void
  285.     {
  286.         $this->imageCaption $imageCaption;
  287.     }
  288.     /**
  289.      * @return string
  290.      */
  291.     public function getIntro()
  292.     {
  293.         return $this->intro;
  294.     }
  295.     /**
  296.      * @param string $intro
  297.      */
  298.     public function setIntro($intro)
  299.     {
  300.         $this->intro $intro;
  301.     }
  302.     /**
  303.      * @return string
  304.      */
  305.     public function getDescription()
  306.     {
  307.         return $this->description;
  308.     }
  309.     /**
  310.      * @param string $description
  311.      */
  312.     public function setDescription($description)
  313.     {
  314.         $this->description $description;
  315.     }
  316.     /**
  317.      * Add keyBenefit
  318.      *
  319.      * @param KeyBenefit $keyBenefit
  320.      * @return Product
  321.      */
  322.     public function addKeyBenefit(KeyBenefit $keyBenefit)
  323.     {
  324.         $keyBenefit->setProduct($this);
  325.         $this->keyBenefits->add($keyBenefit);
  326.         return $this;
  327.     }
  328.     /**
  329.      * Remove keyBenefit
  330.      *
  331.      * @param KeyBenefit $keyBenefit
  332.      */
  333.     public function removeKeyBenefit(KeyBenefit $keyBenefit)
  334.     {
  335.         $this->keyBenefits->removeElement($keyBenefit);
  336.     }
  337.     /**
  338.      * Get keyBenefits
  339.      *
  340.      * @return Collection
  341.      */
  342.     public function getKeyBenefits()
  343.     {
  344.         return $this->keyBenefits;
  345.     }
  346.     /**
  347.      * Set keyBenefits
  348.      *
  349.      */
  350.     public function setKeyBenefits(array $keyBenefits)
  351.     {
  352.         $this->keyBenefits $keyBenefits;
  353.     }
  354.     /**
  355.      * Get category
  356.      *
  357.      * @return SonataClassificationCategory
  358.      */
  359.     public function getCategory()
  360.     {
  361.         return $this->category;
  362.     }
  363.     /**
  364.      * Set category
  365.      *
  366.      * @param SonataClassificationCategory $category
  367.      *
  368.      * @return Product
  369.      */
  370.     public function setCategory(SonataClassificationCategory $category null)
  371.     {
  372.         $this->category $category;
  373.         return $this;
  374.     }
  375.     /**
  376.      * Get slug
  377.      *
  378.      * @return string
  379.      */
  380.     public function getSlug()
  381.     {
  382.         return $this->slug;
  383.     }
  384.     /**
  385.      * Set slug
  386.      *
  387.      * @param string $slug
  388.      *
  389.      * @return Product
  390.      */
  391.     public function setSlug($slug)
  392.     {
  393.         $this->slug $slug;
  394.         return $this;
  395.     }
  396.     /**
  397.      * Get publish
  398.      *
  399.      * @return boolean
  400.      */
  401.     public function getPublish()
  402.     {
  403.         return $this->publish;
  404.     }
  405.     /**
  406.      * Set publish
  407.      *
  408.      * @param boolean $publish
  409.      */
  410.     public function setPublish($publish)
  411.     {
  412.         $this->publish $publish;
  413.     }
  414.     /**
  415.      * Add declinaison
  416.      *
  417.      * @param ProductDeclinaison $declinaison
  418.      *
  419.      * @return Product
  420.      */
  421.     public function addDeclinaison(ProductDeclinaison $declinaison)
  422.     {
  423.         $declinaison->setProduct($this);
  424.         $this->declinaison->add($declinaison);
  425.         return $this;
  426.     }
  427.     /**
  428.      * Remove declinaison
  429.      *
  430.      * @param ProductDeclinaison $declinaison
  431.      */
  432.     public function removeDeclinaison(ProductDeclinaison $declinaison)
  433.     {
  434.         $this->declinaison->removeElement($declinaison);
  435.     }
  436.     /**
  437.      * Get declinaison
  438.      *
  439.      * @return Collection
  440.      */
  441.     public function getDeclinaison()
  442.     {
  443.         return $this->declinaison;
  444.     }
  445.     /**
  446.      * @return mixed
  447.      */
  448.     public function getPosition()
  449.     {
  450.         return $this->position;
  451.     }
  452.     /**
  453.      * @param integer $position
  454.      */
  455.     public function setPosition($position): void
  456.     {
  457.         $this->position $position;
  458.     }
  459. }