Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace My\MoviesBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Gedmo\Mapping\Annotation as Gedmo;
- /**
- * Movie
- *
- * @ORM\Table()
- * @ORM\Entity(repositoryClass="My\MoviesBundle\Entity\MovieRepository")
- * @ORM\HasLifecycleCallbacks
- */
- class Movie
- {
- /**
- * @var integer
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string
- * @ORM\Column(name="name", type="string", length=255)
- */
- private $name;
- /**
- * @var string
- * @ORM\Column(name="slug", type="string", length=48, unique=true)
- * @Gedmo\Slug(fields={"year", "name"}, separator="-", updatable=true, unique=true)
- */
- private $slug;
- /**
- * @var string
- * @ORM\Column(name="description", type="text")
- */
- private $description;
- /**
- * Year has to be string for slugable reason
- * @var string
- * @ORM\Column(name="year", type="string", length=4)
- */
- private $year;
- /**
- * @var Entity ProductionCountry
- * @ORM\ManyToMany(targetEntity="ProductionCountry", inversedBy="movie")
- * @ORM\JoinTable(name="movie__has_production")
- */
- private $production;
- /**
- * @var Category
- * @ORM\ManyToOne(targetEntity="Category", inversedBy="movies")
- */
- private $category;
- /**
- * @var CategorySub
- * @ORM\ManyToOne(targetEntity="CategorySub", inversedBy="movies")
- */
- private $categorysub;
- /**
- * @var integer
- * @ORM\Column(name="length", type="smallint")
- */
- private $length;
- /**
- * @var Entity MovieInfo
- * @ORM\OneToOne(targetEntity="MovieInfo", inversedBy="movie", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
- * @ORM\JoinColumn(name="info_id", referencedColumnName="id", onDelete="cascade")
- */
- private $info;
- /**
- * @var Entity Media
- * @ORM\OneToOne(targetEntity="\Application\Sonata\MediaBundle\Entity\Media")
- */
- private $media;
- /**
- * @var Entity Gallery
- * @ORM\OneToOne(targetEntity="\Application\Sonata\MediaBundle\Entity\Gallery")
- * @ORM\JoinColumn(name="gallery_id", referencedColumnName="id", nullable=false)
- */
- private $gallery;
- /**
- * @var Entity MovieHasOrder
- * @ORM\OneToMany(targetEntity="MovieHasOrder" , mappedBy="movie" , cascade={"all"})
- */
- private $movieOrder;
- /**
- * Convert object to string name
- * @return string $name
- */
- public function __toString() {
- return $this->name;
- }
- /**
- * Check category include given sub-category
- * @return boolean
- */
- public function isCategoryLegal()
- {
- if (!isset($this->categorysub)) return 1;
- $categoryParent = $this->categorysub->getCategory();
- return ($categoryParent->getId() == $this->category->getId());
- }
- /**
- * Get id
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set name
- * @param string $name
- * @return Movie
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * Get name
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Set slug
- * @param string $slug
- * @return Movie
- */
- public function setSlug($slug)
- {
- $this->slug = $slug;
- return $this;
- }
- /**
- * Get slug
- * @return string
- */
- public function getSlug()
- {
- return $this->slug;
- }
- /**
- * Set description
- * @param string $description
- * @return Movie
- */
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
- /**
- * Get description
- * @return string
- */
- public function getDescription()
- {
- return $this->description;
- }
- /**
- * Set premiere
- * @param \DateTime $premiere
- * @return Movie
- */
- public function setPremiere($premiere)
- {
- $this->premiere = $premiere;
- return $this;
- }
- /**
- * Get premiere
- * @return \DateTime
- */
- public function getPremiere()
- {
- return $this->premiere;
- }
- /**
- * Set category
- * @param \My\MoviesBundle\Entity\Category $category
- * @return Movie
- */
- public function setCategory(\My\MoviesBundle\Entity\Category $category = null)
- {
- $this->category = $category;
- return $this;
- }
- /**
- * Get category
- * @return \My\MoviesBundle\Entity\Category
- */
- public function getCategory()
- {
- return $this->category;
- }
- /**
- * Set categorysub
- * @param \My\MoviesBundle\Entity\CategorySub $categorysub
- * @return Movie
- */
- public function setCategorysub(\My\MoviesBundle\Entity\CategorySub $categorysub = null)
- {
- $this->categorysub = $categorysub;
- return $this;
- }
- /**
- * Get categorysub
- * @return \My\MoviesBundle\Entity\CategorySub
- */
- public function getCategorysub()
- {
- return $this->categorysub;
- }
- /**
- * Set year
- * @param string $year
- * @return Movie
- */
- public function setYear($year)
- {
- $this->year = $year;
- return $this;
- }
- /**
- * Get year
- * @return string
- */
- public function getYear()
- {
- return $this->year;
- }
- /**
- * Set length
- * @param integer $length
- * @return Movie
- */
- public function setLength($length)
- {
- $this->length = $length;
- return $this;
- }
- /**
- * Get length
- * @return integer
- */
- public function getLength()
- {
- return $this->length;
- }
- /**
- * Add production
- * @param \My\MoviesBundle\Entity\ProductionCountry $production
- * @return Movie
- */
- public function addProduction(\My\MoviesBundle\Entity\ProductionCountry $production)
- {
- $this->production[] = $production;
- return $this;
- }
- /**
- * Remove production
- * @param \My\MoviesBundle\Entity\ProductionCountry $production
- */
- public function removeProduction(\My\MoviesBundle\Entity\ProductionCountry $production)
- {
- $this->production->removeElement($production);
- }
- /**
- * Get production
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getProduction()
- {
- return $this->production;
- }
- /**
- * Update year data
- * @ORM\PrePersist
- */
- public function preUpload()
- {
- $this->year = $this->info->getPremiereYear();
- }
- /**
- * Update year data
- * @ORM\preUpdate
- */
- public function preUpdate()
- {
- if ($this->year != $this->info->getPremiereYear()) {
- $this->year = $this->info->getPremiereYear();
- }
- }
- /*
- * Constructor
- */
- public function __construct()
- {
- $this->production = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Set info
- * @param \My\MoviesBundle\Entity\MovieInfo $info
- * @return Movie
- */
- public function setInfo(\My\MoviesBundle\Entity\MovieInfo $info = null)
- {
- $this->info = $info;
- return $this;
- }
- /**
- * Get info
- * @return \My\MoviesBundle\Entity\MovieInfo
- */
- public function getInfo()
- {
- return $this->info;
- }
- /**
- * Set media
- * @param \Application\Sonata\MediaBundle\Entity\Media $media
- * @return Movie
- */
- public function setMedia(\Application\Sonata\MediaBundle\Entity\Media $media = null)
- {
- $this->media = $media;
- return $this;
- }
- /**
- * Get media
- * @return \Application\Sonata\MediaBundle\Entity\Media
- */
- public function getMedia()
- {
- return $this->media;
- }
- /**
- * Set gallery
- * @param \Application\Sonata\MediaBundle\Entity\Gallery $gallery
- * @return Movie
- */
- public function setGallery(\Application\Sonata\MediaBundle\Entity\Gallery $gallery = null)
- {
- $this->gallery = $gallery;
- return $this;
- }
- /**
- * Get gallery
- * @return \Application\Sonata\MediaBundle\Entity\Gallery
- */
- public function getGallery()
- {
- return $this->gallery;
- }
- /**
- * Add movieOrder
- * @param \My\MoviesBundle\Entity\MovieHasOrder $movieOrder
- * @return Movie
- */
- public function addMovieOrder(\My\MoviesBundle\Entity\MovieHasOrder $movieOrder)
- {
- $this->movieOrder[] = $movieOrder;
- return $this;
- }
- /**
- * Remove movieOrder
- * @param \My\MoviesBundle\Entity\MovieHasOrder $movieOrder
- */
- public function removeMovieOrder(\My\MoviesBundle\Entity\MovieHasOrder $movieOrder)
- {
- $this->movieOrder->removeElement($movieOrder);
- }
- /**
- * Get movieOrder
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getMovieOrder()
- {
- return $this->movieOrder;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement