Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace FermierMalin\Bundle\GrowerBundle\Entity;
- // Doctrine
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping AS ORM;
- use FermierMalin\Bundle\UserBundle\Entity\User;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Symfony\Component\Validator\Constraints as Assert;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- /**
- * @ORM\Entity (repositoryClass="FermierMalin\Bundle\GrowerBundle\Entity\GrowerRepository")
- * @ORM\Table (name="grower", uniqueConstraints={@ORM\UniqueConstraint(name="siret", columns={"siret"}), @ORM\UniqueConstraint(name="slug", columns={"slug"})})
- * @UniqueEntity(fields="siret", message="Ce numéro de SIRET existe déjà")
- * @ORM\HasLifecycleCallbacks
- */
- class Grower
- {
- public function __construct() {
- $this->images = new ArrayCollection();
- $this->labels = new ArrayCollection();
- $this->favorites = new ArrayCollection();
- $this->comments = new ArrayCollection();
- $this->statistics_view = new ArrayCollection();
- $this->products = new ArrayCollection();
- }
- /**
- * @ORM\Id
- * @ORM\Column (type="integer")
- * @ORM\GeneratedValue (strategy="AUTO")
- */
- private $id;
- /**
- * @Assert\NotBlank(message="Le numéro de SIRET est requis")
- * @ORM\Column (name="siret", type="string", length=255, unique=true)
- */
- private $siret; // TODO : Controle siret + unique
- /**
- * @Assert\NotBlank(message="Le nom de l'exploitation est requis")
- * @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")
- * @ORM\Column(name="name", type="string", length=255)
- */
- private $name;
- /**
- * @Gedmo\Slug(fields={"name"})
- * @ORM\Column(name="slug", type="string", length=255, unique=true)
- */
- private $slug;
- /**
- * @Assert\NotBlank(message="La mini-description est requise")
- * @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")
- * @ORM\Column(name="slogan", type="string", length=255)
- */
- private $slogan;
- /**
- * @Assert\NotBlank(message="La description est requise")
- * @ORM\Column(name="description", type="text")
- */
- private $description;
- /**
- * @Assert\NotBlank(message="Le numéro de téléphone est requis")
- * @ORM\Column(name="phone", type="string", length=255)
- */
- private $phone; // TODO : valid phone
- /**
- * @ORM\Column(name="phoneBis", type="string", length=255, nullable=true)
- */
- private $phoneBis; // TODO : valid phone
- /**
- * @Assert\Url(message="L'adresse n'est pas valide")
- * @ORM\Column(name="site_web", type="string", nullable=true)
- */
- private $siteWeb;
- /**
- * @Assert\Url(message="L'adresse facebook n'est pas valide")
- * @ORM\Column(name="facebook", type="string", nullable=true)
- */
- private $facebook;
- /**
- * @Assert\Url(message="L'adresse twitter n'est pas valide")
- * @ORM\Column(name="twitter", type="string", nullable=true)
- */
- private $twitter;
- /**
- * @ORM\ManyToOne(targetEntity="CategoryGrower", inversedBy="growers")
- * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
- **/
- private $category;
- /**
- * @ORM\OneToMany(targetEntity="Product", mappedBy="grower", cascade={"persist"})
- **/
- private $products;
- /**
- * @var Collection
- * @ORM\OneToMany(targetEntity="ImageGrower", mappedBy="grower", cascade={"persist"})
- **/
- private $images;
- /**
- * @var Collection
- * @ORM\OneToMany(targetEntity="CommentGrower", mappedBy="grower", cascade={"persist"})
- **/
- private $comments;
- /**
- * @var Collection
- * @ORM\OneToMany(targetEntity="StatisticsViewGrower", mappedBy="grower", cascade={"persist"})
- **/
- private $statistics_view;
- /**
- * @var Collection
- * @ORM\ManyToMany(targetEntity="Label", inversedBy="growers")
- * @ORM\JoinTable(name="growers_labels")
- **/
- private $labels;
- /**
- * @ORM\ManyToMany(targetEntity="FermierMalin\Bundle\UserBundle\Entity\User", mappedBy="favorites_grower")
- **/
- private $favorites;
- /**
- * @ORM\OneToOne(targetEntity="Hours", cascade={"persist"})
- * @ORM\JoinColumn(name="hours_id", referencedColumnName="id")
- **/
- private $hours;
- /**
- * @ORM\Column(name="created_at", type="datetime")
- */
- private $createdAt;
- /**
- * @ORM\Column(name="updated_at", type="datetime")
- */
- private $updatedAt;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set siret
- *
- * @param string $siret
- * @return Grower
- */
- public function setSiret($siret)
- {
- $this->siret = $siret;
- return $this;
- }
- /**
- * Get siret
- *
- * @return string
- */
- public function getSiret()
- {
- return $this->siret;
- }
- /**
- * Set name
- *
- * @param string $name
- * @return Grower
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * Get name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Get slug
- *
- * @return string
- */
- public function getSlug()
- {
- return $this->slug;
- }
- /**
- * Set slogan
- *
- * @param string $slogan
- * @return Grower
- */
- public function setSlogan($slogan)
- {
- $this->slogan = $slogan;
- return $this;
- }
- /**
- * Get slogan
- *
- * @return string
- */
- public function getSlogan()
- {
- return $this->slogan;
- }
- /**
- * Set description
- *
- * @param string $description
- * @return Grower
- */
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
- /**
- * Get description
- *
- * @return string
- */
- public function getDescription()
- {
- return $this->description;
- }
- /**
- * Set phone
- *
- * @param string $phone
- * @return Grower
- */
- public function setPhone($phone)
- {
- $this->phone = $phone;
- return $this;
- }
- /**
- * Get phone
- *
- * @return string
- */
- public function getPhone()
- {
- return $this->phone;
- }
- /**
- * Set phoneBis
- *
- * @param string $phoneBis
- * @return Grower
- */
- public function setPhoneBis($phoneBis)
- {
- $this->phoneBis = $phoneBis;
- return $this;
- }
- /**
- * Get phoneBis
- *
- * @return string
- */
- public function getPhoneBis()
- {
- return $this->phoneBis;
- }
- /**
- * Set siteWeb
- *
- * @param string $siteWeb
- * @return Grower
- */
- public function setSiteWeb($siteWeb)
- {
- $this->siteWeb = $siteWeb;
- return $this;
- }
- /**
- * Get siteWeb
- *
- * @return string
- */
- public function getSiteWeb()
- {
- return $this->siteWeb;
- }
- /**
- * Set facebook
- *
- * @param string $facebook
- * @return Grower
- */
- public function setFacebook($facebook)
- {
- $this->facebook = $facebook;
- return $this;
- }
- /**
- * Get facebook
- *
- * @return string
- */
- public function getFacebook()
- {
- return $this->facebook;
- }
- /**
- * Set twitter
- *
- * @param string $twitter
- * @return Grower
- */
- public function setTwitter($twitter)
- {
- $this->twitter = $twitter;
- return $this;
- }
- /**
- * Get twitter
- *
- * @return string
- */
- public function getTwitter()
- {
- return $this->twitter;
- }
- /**
- * Set createdAt
- *
- * @param \DateTime $createdAt
- * @return Grower
- */
- public function setCreatedAt($createdAt)
- {
- $this->createdAt = $createdAt;
- return $this;
- }
- /**
- * Get createdAt
- *
- * @return \DateTime
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
- /**
- * Set updatedAt
- *
- * @param \DateTime $updatedAt
- * @return Grower
- */
- public function setUpdatedAt($updatedAt)
- {
- $this->updatedAt = $updatedAt;
- return $this;
- }
- /**
- * Get updatedAt
- *
- * @return \DateTime
- */
- public function getUpdatedAt()
- {
- return $this->updatedAt;
- }
- /**
- * @ORM\PrePersist
- * @ORM\PreUpdate
- */
- public function updatedTimestamps()
- {
- $this->setUpdatedAt(new \DateTime('now'));
- if ($this->getCreatedAt() == null) {
- $this->setCreatedAt(new \DateTime('now'));
- }
- }
- /**
- * Add images
- *
- * @param ImageGrower $images
- * @return Grower
- */
- public function addImage(ImageGrower $images)
- {
- $this->images[] = $images;
- return $this;
- }
- /**
- * Remove images
- *
- * @param ImageGrower $images
- */
- public function removeImage(ImageGrower $images)
- {
- $this->images->removeElement($images);
- }
- /**
- * Get images
- *
- * @return Collection
- */
- public function getImages()
- {
- return $this->images;
- }
- /**
- * Add labels
- *
- * @param Label $labels
- * @return Grower
- */
- public function addLabel(Label $labels)
- {
- $this->labels[] = $labels;
- return $this;
- }
- /**
- * Remove labels
- *
- * @param Label $labels
- */
- public function removeLabel(Label $labels)
- {
- $this->labels->removeElement($labels);
- }
- /**
- * Get labels
- *
- * @return Collection
- */
- public function getLabels()
- {
- return $this->labels;
- }
- /**
- * Add favorites
- *
- * @param User $favorites
- * @return Grower
- */
- public function addFavorite(User $favorites)
- {
- $this->favorites[] = $favorites;
- return $this;
- }
- /**
- * Remove favorites
- *
- * @param User $favorites
- */
- public function removeFavorite(User $favorites)
- {
- $this->favorites->removeElement($favorites);
- }
- /**
- * Get favorites
- *
- * @return Collection
- */
- public function getFavorites()
- {
- return $this->favorites;
- }
- /**
- * Add comments
- *
- * @param CommentGrower $comments
- * @return Grower
- */
- public function addComment(CommentGrower $comments)
- {
- $this->comments[] = $comments;
- return $this;
- }
- /**
- * Remove comments
- *
- * @param CommentGrower $comments
- */
- public function removeComment(CommentGrower $comments)
- {
- $this->comments->removeElement($comments);
- }
- /**
- * Get comments
- *
- * @return Collection
- */
- public function getComments()
- {
- return $this->comments;
- }
- /**
- * Set hours
- *
- * @param Hours $hours
- * @return Grower
- */
- public function setHours(Hours $hours = null)
- {
- $this->hours = $hours;
- return $this;
- }
- /**
- * Get hours
- *
- * @return Hours
- */
- public function getHours()
- {
- return $this->hours;
- }
- /**
- * Add statistics_view
- *
- * @param StatisticsViewGrower $statisticsView
- * @return Grower
- */
- public function addStatisticsViewGrower(StatisticsViewGrower $statisticsView)
- {
- $this->statistics_view[] = $statisticsView;
- return $this;
- }
- /**
- * Remove statistics_view
- *
- * @param StatisticsViewGrower $statisticsView
- */
- public function removeStatisticsView(StatisticsViewGrower $statisticsView)
- {
- $this->statistics_view->removeElement($statisticsView);
- }
- /**
- * Get statistics_view
- *
- * @return Collection
- */
- public function getStatisticsView()
- {
- return $this->statistics_view;
- }
- /**
- * Set category
- *
- * @param CategoryGrower $category
- * @return Grower
- */
- public function setCategory(CategoryGrower $category = null)
- {
- $this->category = $category;
- return $this;
- }
- /**
- * Get category
- *
- * @return CategoryGrower
- */
- public function getCategory()
- {
- return $this->category;
- }
- /**
- * Add products
- *
- * @param Product $products
- * @return Grower
- */
- public function addProduct(Product $products)
- {
- $this->products[] = $products;
- return $this;
- }
- /**
- * Remove products
- *
- * @param Product $products
- */
- public function removeProduct(Product $products)
- {
- $this->products->removeElement($products);
- }
- /**
- * Get products
- *
- * @return Collection
- */
- public function getProducts()
- {
- return $this->products;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement