Advertisement
Guest User

Untitled

a guest
Oct 31st, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.83 KB | None | 0 0
  1. <?php
  2. namespace FermierMalin\Bundle\GrowerBundle\Entity;
  3.  
  4. // Doctrine
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping AS ORM;
  8. use FermierMalin\Bundle\UserBundle\Entity\User;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12.  
  13. /**
  14.  * @ORM\Entity (repositoryClass="FermierMalin\Bundle\GrowerBundle\Entity\GrowerRepository")
  15.  * @ORM\Table (name="grower", uniqueConstraints={@ORM\UniqueConstraint(name="siret", columns={"siret"}), @ORM\UniqueConstraint(name="slug", columns={"slug"})})
  16.  * @UniqueEntity(fields="siret", message="Ce numéro de SIRET existe déjà")
  17.  * @ORM\HasLifecycleCallbacks
  18.  */
  19. class Grower
  20. {
  21.     public function __construct() {
  22.         $this->images = new ArrayCollection();
  23.         $this->labels = new ArrayCollection();
  24.         $this->favorites = new ArrayCollection();
  25.         $this->comments = new ArrayCollection();
  26.         $this->statistics_view = new ArrayCollection();
  27.         $this->products = new ArrayCollection();
  28.     }
  29.  
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\Column (type="integer")
  33.      * @ORM\GeneratedValue (strategy="AUTO")
  34.      */
  35.     private $id;
  36.  
  37.     /**
  38.      * @Assert\NotBlank(message="Le numéro de SIRET est requis")
  39.      * @ORM\Column (name="siret", type="string", length=255, unique=true)
  40.      */
  41.     private $siret; // TODO : Controle siret + unique
  42.  
  43.     /**
  44.      * @Assert\NotBlank(message="Le nom de l'exploitation est requis")
  45.      * @Assert\Length(min=2, max=100, minMessage="Le nom de l'exploitation doit contenir au moins {{ limit }} caractères", maxMessage="Le nom de l'exploitation doit contenir moins de {{ limit }} caractères")
  46.      * @ORM\Column(name="name", type="string", length=255)
  47.      */
  48.     private $name;
  49.  
  50.     /**
  51.      * @Gedmo\Slug(fields={"name"})
  52.      * @ORM\Column(name="slug", type="string", length=255, unique=true)
  53.      */
  54.     private $slug;
  55.  
  56.     /**
  57.      * @Assert\NotBlank(message="La mini-description est requise")
  58.      * @Assert\Length(min=2, max=100, minMessage="La mini-description doit contenir au moins {{ limit }} caractères", maxMessage="La mini-description doit contenir moins de {{ limit }} caractères")
  59.      * @ORM\Column(name="slogan", type="string", length=255)
  60.      */
  61.     private $slogan;
  62.  
  63.     /**
  64.      * @Assert\NotBlank(message="La description est requise")
  65.      * @ORM\Column(name="description", type="text")
  66.      */
  67.     private $description;
  68.  
  69.     /**
  70.      * @Assert\NotBlank(message="Le numéro de téléphone est requis")
  71.      * @ORM\Column(name="phone", type="string", length=255)
  72.      */
  73.     private $phone; // TODO : valid phone
  74.  
  75.     /**
  76.      * @ORM\Column(name="phoneBis", type="string", length=255, nullable=true)
  77.      */
  78.     private $phoneBis; // TODO : valid phone
  79.  
  80.     /**
  81.      * @Assert\Url(message="L'adresse n'est pas valide")
  82.      * @ORM\Column(name="site_web", type="string", nullable=true)
  83.      */
  84.     private $siteWeb;
  85.  
  86.     /**
  87.      * @Assert\Url(message="L'adresse facebook n'est pas valide")
  88.      * @ORM\Column(name="facebook", type="string", nullable=true)
  89.      */
  90.     private $facebook;
  91.  
  92.     /**
  93.      * @Assert\Url(message="L'adresse twitter n'est pas valide")
  94.      * @ORM\Column(name="twitter", type="string", nullable=true)
  95.      */
  96.     private $twitter;
  97.  
  98.     /**
  99.      * @ORM\ManyToOne(targetEntity="CategoryGrower", inversedBy="growers")
  100.      * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
  101.      **/
  102.     private $category;
  103.  
  104.     /**
  105.      * @ORM\OneToMany(targetEntity="Product", mappedBy="grower", cascade={"persist"})
  106.      **/
  107.     private $products;
  108.  
  109.     /**
  110.      * @var Collection
  111.      * @ORM\OneToMany(targetEntity="ImageGrower", mappedBy="grower", cascade={"persist"})
  112.      **/
  113.     private $images;
  114.  
  115.     /**
  116.      * @var Collection
  117.      * @ORM\OneToMany(targetEntity="CommentGrower", mappedBy="grower", cascade={"persist"})
  118.      **/
  119.     private $comments;
  120.  
  121.     /**
  122.      * @var Collection
  123.      * @ORM\OneToMany(targetEntity="StatisticsViewGrower", mappedBy="grower", cascade={"persist"})
  124.      **/
  125.     private $statistics_view;
  126.  
  127.     /**
  128.      * @var Collection
  129.      * @ORM\ManyToMany(targetEntity="Label", inversedBy="growers")
  130.      * @ORM\JoinTable(name="growers_labels")
  131.      **/
  132.     private $labels;
  133.  
  134.     /**
  135.      * @ORM\ManyToMany(targetEntity="FermierMalin\Bundle\UserBundle\Entity\User", mappedBy="favorites_grower")
  136.      **/
  137.     private $favorites;
  138.  
  139.     /**
  140.      * @ORM\OneToOne(targetEntity="Hours", cascade={"persist"})
  141.      * @ORM\JoinColumn(name="hours_id", referencedColumnName="id")
  142.      **/
  143.     private $hours;
  144.  
  145.     /**
  146.      * @ORM\Column(name="created_at", type="datetime")
  147.      */
  148.     private $createdAt;
  149.  
  150.     /**
  151.      * @ORM\Column(name="updated_at", type="datetime")
  152.      */
  153.     private $updatedAt;
  154.  
  155.     /**
  156.      * Get id
  157.      *
  158.      * @return integer
  159.      */
  160.     public function getId()
  161.     {
  162.         return $this->id;
  163.     }
  164.  
  165.     /**
  166.      * Set siret
  167.      *
  168.      * @param string $siret
  169.      * @return Grower
  170.      */
  171.     public function setSiret($siret)
  172.     {
  173.         $this->siret = $siret;
  174.  
  175.         return $this;
  176.     }
  177.  
  178.     /**
  179.      * Get siret
  180.      *
  181.      * @return string
  182.      */
  183.     public function getSiret()
  184.     {
  185.         return $this->siret;
  186.     }
  187.  
  188.     /**
  189.      * Set name
  190.      *
  191.      * @param string $name
  192.      * @return Grower
  193.      */
  194.     public function setName($name)
  195.     {
  196.         $this->name = $name;
  197.  
  198.         return $this;
  199.     }
  200.  
  201.     /**
  202.      * Get name
  203.      *
  204.      * @return string
  205.      */
  206.     public function getName()
  207.     {
  208.         return $this->name;
  209.     }
  210.  
  211.     /**
  212.      * Get slug
  213.      *
  214.      * @return string
  215.      */
  216.     public function getSlug()
  217.     {
  218.         return $this->slug;
  219.     }
  220.  
  221.     /**
  222.      * Set slogan
  223.      *
  224.      * @param string $slogan
  225.      * @return Grower
  226.      */
  227.     public function setSlogan($slogan)
  228.     {
  229.         $this->slogan = $slogan;
  230.  
  231.         return $this;
  232.     }
  233.  
  234.     /**
  235.      * Get slogan
  236.      *
  237.      * @return string
  238.      */
  239.     public function getSlogan()
  240.     {
  241.         return $this->slogan;
  242.     }
  243.  
  244.     /**
  245.      * Set description
  246.      *
  247.      * @param string $description
  248.      * @return Grower
  249.      */
  250.     public function setDescription($description)
  251.     {
  252.         $this->description = $description;
  253.  
  254.         return $this;
  255.     }
  256.  
  257.     /**
  258.      * Get description
  259.      *
  260.      * @return string
  261.      */
  262.     public function getDescription()
  263.     {
  264.         return $this->description;
  265.     }
  266.  
  267.     /**
  268.      * Set phone
  269.      *
  270.      * @param string $phone
  271.      * @return Grower
  272.      */
  273.     public function setPhone($phone)
  274.     {
  275.         $this->phone = $phone;
  276.  
  277.         return $this;
  278.     }
  279.  
  280.     /**
  281.      * Get phone
  282.      *
  283.      * @return string
  284.      */
  285.     public function getPhone()
  286.     {
  287.         return $this->phone;
  288.     }
  289.  
  290.     /**
  291.      * Set phoneBis
  292.      *
  293.      * @param string $phoneBis
  294.      * @return Grower
  295.      */
  296.     public function setPhoneBis($phoneBis)
  297.     {
  298.         $this->phoneBis = $phoneBis;
  299.  
  300.         return $this;
  301.     }
  302.  
  303.     /**
  304.      * Get phoneBis
  305.      *
  306.      * @return string
  307.      */
  308.     public function getPhoneBis()
  309.     {
  310.         return $this->phoneBis;
  311.     }
  312.  
  313.     /**
  314.      * Set siteWeb
  315.      *
  316.      * @param string $siteWeb
  317.      * @return Grower
  318.      */
  319.     public function setSiteWeb($siteWeb)
  320.     {
  321.         $this->siteWeb = $siteWeb;
  322.  
  323.         return $this;
  324.     }
  325.  
  326.     /**
  327.      * Get siteWeb
  328.      *
  329.      * @return string
  330.      */
  331.     public function getSiteWeb()
  332.     {
  333.         return $this->siteWeb;
  334.     }
  335.  
  336.     /**
  337.      * Set facebook
  338.      *
  339.      * @param string $facebook
  340.      * @return Grower
  341.      */
  342.     public function setFacebook($facebook)
  343.     {
  344.         $this->facebook = $facebook;
  345.  
  346.         return $this;
  347.     }
  348.  
  349.     /**
  350.      * Get facebook
  351.      *
  352.      * @return string
  353.      */
  354.     public function getFacebook()
  355.     {
  356.         return $this->facebook;
  357.     }
  358.  
  359.     /**
  360.      * Set twitter
  361.      *
  362.      * @param string $twitter
  363.      * @return Grower
  364.      */
  365.     public function setTwitter($twitter)
  366.     {
  367.         $this->twitter = $twitter;
  368.  
  369.         return $this;
  370.     }
  371.  
  372.     /**
  373.      * Get twitter
  374.      *
  375.      * @return string
  376.      */
  377.     public function getTwitter()
  378.     {
  379.         return $this->twitter;
  380.     }
  381.  
  382.     /**
  383.      * Set createdAt
  384.      *
  385.      * @param \DateTime $createdAt
  386.      * @return Grower
  387.      */
  388.     public function setCreatedAt($createdAt)
  389.     {
  390.         $this->createdAt = $createdAt;
  391.  
  392.         return $this;
  393.     }
  394.  
  395.     /**
  396.      * Get createdAt
  397.      *
  398.      * @return \DateTime
  399.      */
  400.     public function getCreatedAt()
  401.     {
  402.         return $this->createdAt;
  403.     }
  404.  
  405.     /**
  406.      * Set updatedAt
  407.      *
  408.      * @param \DateTime $updatedAt
  409.      * @return Grower
  410.      */
  411.     public function setUpdatedAt($updatedAt)
  412.     {
  413.         $this->updatedAt = $updatedAt;
  414.  
  415.         return $this;
  416.     }
  417.  
  418.     /**
  419.      * Get updatedAt
  420.      *
  421.      * @return \DateTime
  422.      */
  423.     public function getUpdatedAt()
  424.     {
  425.         return $this->updatedAt;
  426.     }
  427.  
  428.     /**
  429.      * @ORM\PrePersist
  430.      * @ORM\PreUpdate
  431.      */
  432.     public function updatedTimestamps()
  433.     {
  434.         $this->setUpdatedAt(new \DateTime('now'));
  435.  
  436.         if ($this->getCreatedAt() == null) {
  437.             $this->setCreatedAt(new \DateTime('now'));
  438.         }
  439.     }
  440.  
  441.     /**
  442.      * Add images
  443.      *
  444.      * @param ImageGrower $images
  445.      * @return Grower
  446.      */
  447.     public function addImage(ImageGrower $images)
  448.     {
  449.         $this->images[] = $images;
  450.  
  451.         return $this;
  452.     }
  453.  
  454.     /**
  455.      * Remove images
  456.      *
  457.      * @param ImageGrower $images
  458.      */
  459.     public function removeImage(ImageGrower $images)
  460.     {
  461.         $this->images->removeElement($images);
  462.     }
  463.  
  464.     /**
  465.      * Get images
  466.      *
  467.      * @return Collection
  468.      */
  469.     public function getImages()
  470.     {
  471.         return $this->images;
  472.     }
  473.  
  474.     /**
  475.      * Add labels
  476.      *
  477.      * @param Label $labels
  478.      * @return Grower
  479.      */
  480.     public function addLabel(Label $labels)
  481.     {
  482.         $this->labels[] = $labels;
  483.  
  484.         return $this;
  485.     }
  486.  
  487.     /**
  488.      * Remove labels
  489.      *
  490.      * @param Label $labels
  491.      */
  492.     public function removeLabel(Label $labels)
  493.     {
  494.         $this->labels->removeElement($labels);
  495.     }
  496.  
  497.     /**
  498.      * Get labels
  499.      *
  500.      * @return Collection
  501.      */
  502.     public function getLabels()
  503.     {
  504.         return $this->labels;
  505.     }
  506.  
  507.     /**
  508.      * Add favorites
  509.      *
  510.      * @param User $favorites
  511.      * @return Grower
  512.      */
  513.     public function addFavorite(User $favorites)
  514.     {
  515.         $this->favorites[] = $favorites;
  516.  
  517.         return $this;
  518.     }
  519.  
  520.     /**
  521.      * Remove favorites
  522.      *
  523.      * @param User $favorites
  524.      */
  525.     public function removeFavorite(User $favorites)
  526.     {
  527.         $this->favorites->removeElement($favorites);
  528.     }
  529.  
  530.     /**
  531.      * Get favorites
  532.      *
  533.      * @return Collection
  534.      */
  535.     public function getFavorites()
  536.     {
  537.         return $this->favorites;
  538.     }
  539.  
  540.     /**
  541.      * Add comments
  542.      *
  543.      * @param CommentGrower $comments
  544.      * @return Grower
  545.      */
  546.     public function addComment(CommentGrower $comments)
  547.     {
  548.         $this->comments[] = $comments;
  549.  
  550.         return $this;
  551.     }
  552.  
  553.     /**
  554.      * Remove comments
  555.      *
  556.      * @param CommentGrower $comments
  557.      */
  558.     public function removeComment(CommentGrower $comments)
  559.     {
  560.         $this->comments->removeElement($comments);
  561.     }
  562.  
  563.     /**
  564.      * Get comments
  565.      *
  566.      * @return Collection
  567.      */
  568.     public function getComments()
  569.     {
  570.         return $this->comments;
  571.     }
  572.  
  573.     /**
  574.      * Set hours
  575.      *
  576.      * @param Hours $hours
  577.      * @return Grower
  578.      */
  579.     public function setHours(Hours $hours = null)
  580.     {
  581.         $this->hours = $hours;
  582.  
  583.         return $this;
  584.     }
  585.  
  586.     /**
  587.      * Get hours
  588.      *
  589.      * @return Hours
  590.      */
  591.     public function getHours()
  592.     {
  593.         return $this->hours;
  594.     }
  595.  
  596.     /**
  597.      * Add statistics_view
  598.      *
  599.      * @param StatisticsViewGrower $statisticsView
  600.      * @return Grower
  601.      */
  602.     public function addStatisticsViewGrower(StatisticsViewGrower $statisticsView)
  603.     {
  604.         $this->statistics_view[] = $statisticsView;
  605.  
  606.         return $this;
  607.     }
  608.  
  609.     /**
  610.      * Remove statistics_view
  611.      *
  612.      * @param StatisticsViewGrower $statisticsView
  613.      */
  614.     public function removeStatisticsView(StatisticsViewGrower $statisticsView)
  615.     {
  616.         $this->statistics_view->removeElement($statisticsView);
  617.     }
  618.  
  619.     /**
  620.      * Get statistics_view
  621.      *
  622.      * @return Collection
  623.      */
  624.     public function getStatisticsView()
  625.     {
  626.         return $this->statistics_view;
  627.     }
  628.  
  629.     /**
  630.      * Set category
  631.      *
  632.      * @param CategoryGrower $category
  633.      * @return Grower
  634.      */
  635.     public function setCategory(CategoryGrower $category = null)
  636.     {
  637.         $this->category = $category;
  638.  
  639.         return $this;
  640.     }
  641.  
  642.     /**
  643.      * Get category
  644.      *
  645.      * @return CategoryGrower
  646.      */
  647.     public function getCategory()
  648.     {
  649.         return $this->category;
  650.     }
  651.  
  652.     /**
  653.      * Add products
  654.      *
  655.      * @param Product $products
  656.      * @return Grower
  657.      */
  658.     public function addProduct(Product $products)
  659.     {
  660.         $this->products[] = $products;
  661.  
  662.         return $this;
  663.     }
  664.  
  665.     /**
  666.      * Remove products
  667.      *
  668.      * @param Product $products
  669.      */
  670.     public function removeProduct(Product $products)
  671.     {
  672.         $this->products->removeElement($products);
  673.     }
  674.  
  675.     /**
  676.      * Get products
  677.      *
  678.      * @return Collection
  679.      */
  680.     public function getProducts()
  681.     {
  682.         return $this->products;
  683.     }
  684. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement