src/Notaris/AdminBundle/Entity/Video.php line 19

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: lisavandaele
  5.  * Date: 30/01/15
  6.  * Time: 12:53
  7.  */
  8. namespace Notaris\AdminBundle\Entity;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass="VideoRepository")
  14.  * @ORM\Table(name="video")
  15.  */
  16. class Video {
  17.     /**
  18.      * @var integer
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
  27.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
  28.      */
  29.     private $user;
  30.     /**
  31.      * @Gedmo\Timestampable(on="create")
  32.      * @ORM\Column(name="created", type="datetime")
  33.      */
  34.     private $created;
  35.     /**
  36.      * @ORM\Column(name="updated", type="datetime")
  37.      * @Gedmo\Timestampable(on="update")
  38.      */
  39.     private $updated;
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="locale", type="string", length=5)
  44.      */
  45.     private $locale;
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="title", type="string", length=255)
  50.      */
  51.     private $title;
  52.     /**
  53.      * @Gedmo\Slug(fields={"title"})
  54.      * @ORM\Column(length=128, unique=true)
  55.      */
  56.     private $slug;
  57.     /**
  58.      * @ORM\Column(type="text", name="description")
  59.      */
  60.     private $description;
  61.     /**
  62.      * @ORM\OneToOne(targetEntity="Asset")
  63.      * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
  64.      */
  65.     protected $asset;
  66.     /**
  67.      * @var integer
  68.      *
  69.      * @ORM\Column(type="integer", name="minutes", nullable=true)
  70.      */
  71.     private $minutes;
  72.     /**
  73.      * @var string
  74.      *
  75.      * @ORM\Column(name="source", type="string", length=255)
  76.      */
  77.     private $source;
  78.     /**
  79.      * @ORM\Column(type="boolean", name="is_active")
  80.      * @Assert\Type("boolean")
  81.      */
  82.     private $isActive;
  83.     /**
  84.      * @ORM\Column(name="pub_date", type="datetime")
  85.      */
  86.     private $publicationDate;
  87.     /**
  88.      * @ORM\OneToOne(targetEntity="News", inversedBy="video", cascade={"remove"})
  89.      * @ORM\JoinColumn(name="news_id", referencedColumnName="id", onDelete="SET NULL")
  90.      */
  91.     protected $news;
  92.     /**
  93.      * @ORM\OneToOne(targetEntity="NewsIzimiInfo", inversedBy="video", cascade={"remove"})
  94.      * @ORM\JoinColumn(name="news_izimi_info_id", referencedColumnName="id", onDelete="SET NULL")
  95.      */
  96.     protected $newsIzimiInfo;
  97.     /**
  98.      * @ORM\Column(type="boolean", name="is_varia")
  99.      * @Assert\Type("boolean")
  100.      */
  101.     private $isVaria;
  102.     /**
  103.      * @ORM\Column(type="boolean", name="is_varia_primary", nullable=true)
  104.      * @Assert\Type("boolean")
  105.      */
  106.     private $isVariaPrimary;
  107.     /**
  108.      * @var integer
  109.      *
  110.      * @ORM\Column(type="integer", name="varia_position", nullable=true)
  111.      */
  112.     private $variaPosition;
  113.     /**
  114.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Subsite")
  115.      * @ORM\JoinColumn(name="primary_subsite", referencedColumnName="id", onDelete="SET NULL")
  116.      */
  117.     private $primarySubsite;
  118.     /**
  119.      * @ORM\ManyToMany(targetEntity="Tag", inversedBy="videos")
  120.      * @ORM\JoinTable(name="tag_video")
  121.      */
  122.     protected $tags;
  123.     /**
  124.      * @ORM\OneToMany(targetEntity="VideoSubsite", mappedBy="video")
  125.      * @ORM\OrderBy({"position" = "asc"})
  126.      */
  127.     private $subsites;
  128.     /**
  129.      * @ORM\ManyToMany(targetEntity="IzimiCategory")
  130.      * @ORM\JoinTable(name="video_izimi_category")
  131.      */
  132.     protected $categories;
  133.     /**
  134.      * @ORM\Column(type="boolean", name="is_izimi")
  135.      * @Assert\Type("boolean")
  136.      */
  137.     private $isIzimi;
  138.     /**
  139.      * @ORM\OneToOne(targetEntity="Meta")
  140.      * @ORM\JoinColumn(name="meta_id", referencedColumnName="id")
  141.      */
  142.     protected $meta;
  143.     /**
  144.      * @var integer
  145.      *
  146.      * @ORM\Column(type="integer", name="count_clicked")
  147.      */
  148.     private $countClicked = 0;
  149.     /**
  150.      * Constructor
  151.      */
  152.     public function __construct()
  153.     {
  154.         $this->tags = new \Doctrine\Common\Collections\ArrayCollection();
  155.         $this->isIzimi = false;
  156.     }
  157.     /**
  158.      * @return string
  159.      */
  160.     public function getRelatedTo(){
  161.         if($this->getSubsites()){
  162.             $default_general = 'Varia';
  163.             $count = count($this->getSubsites());
  164.             if(!$count && $this->getIsVaria()){
  165.                 return  $default_general;
  166.             }
  167.             elseif($count>=1){
  168.                 if($this->getPrimarySubsite()){
  169.                     return $this->getPrimarySubsite();
  170.                 }
  171.                 elseif($this->getIsVariaPrimary()){
  172.                     return $default_general;
  173.                 }
  174.                 else{
  175.                     $subsites = $this->getSubsites();
  176.                     return $subsites[0]->getSubsite();
  177.                 }
  178.             }
  179.         }
  180.         return '';
  181.     }
  182.     /**
  183.      * Get id
  184.      *
  185.      * @return integer
  186.      */
  187.     public function getId()
  188.     {
  189.         return $this->id;
  190.     }
  191.     /**
  192.      * Set created
  193.      *
  194.      * @param \DateTime $created
  195.      * @return Video
  196.      */
  197.     public function setCreated($created)
  198.     {
  199.         $this->created = $created;
  200.         return $this;
  201.     }
  202.     /**
  203.      * Get created
  204.      *
  205.      * @return \DateTime
  206.      */
  207.     public function getCreated()
  208.     {
  209.         return $this->created;
  210.     }
  211.     /**
  212.      * Set updated
  213.      *
  214.      * @param \DateTime $updated
  215.      * @return Video
  216.      */
  217.     public function setUpdated($updated)
  218.     {
  219.         $this->updated = $updated;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get updated
  224.      *
  225.      * @return \DateTime
  226.      */
  227.     public function getUpdated()
  228.     {
  229.         return $this->updated;
  230.     }
  231.     /**
  232.      * Set locale
  233.      *
  234.      * @param string $locale
  235.      * @return Video
  236.      */
  237.     public function setLocale($locale)
  238.     {
  239.         $this->locale = $locale;
  240.         return $this;
  241.     }
  242.     /**
  243.      * Get locale
  244.      *
  245.      * @return string
  246.      */
  247.     public function getLocale()
  248.     {
  249.         return $this->locale;
  250.     }
  251.     /**
  252.      * Set title
  253.      *
  254.      * @param string $title
  255.      * @return Video
  256.      */
  257.     public function setTitle($title)
  258.     {
  259.         $this->title = $title;
  260.         return $this;
  261.     }
  262.     /**
  263.      * Get title
  264.      *
  265.      * @return string
  266.      */
  267.     public function getTitle()
  268.     {
  269.         return $this->title;
  270.     }
  271.     /**
  272.      * Set slug
  273.      *
  274.      * @param string $slug
  275.      * @return Video
  276.      */
  277.     public function setSlug($slug)
  278.     {
  279.         $this->slug = $slug;
  280.         return $this;
  281.     }
  282.     /**
  283.      * Get slug
  284.      *
  285.      * @return string
  286.      */
  287.     public function getSlug()
  288.     {
  289.         return $this->slug;
  290.     }
  291.     /**
  292.      * Set description
  293.      *
  294.      * @param string $description
  295.      * @return Video
  296.      */
  297.     public function setDescription($description)
  298.     {
  299.         $this->description = $description;
  300.         return $this;
  301.     }
  302.     /**
  303.      * Get description
  304.      *
  305.      * @return string
  306.      */
  307.     public function getDescription()
  308.     {
  309.         return $this->description;
  310.     }
  311.     /**
  312.      * Set minutes
  313.      *
  314.      * @param integer $minutes
  315.      * @return Video
  316.      */
  317.     public function setMinutes($minutes)
  318.     {
  319.         $this->minutes = $minutes;
  320.         return $this;
  321.     }
  322.     /**
  323.      * Get minutes
  324.      *
  325.      * @return integer
  326.      */
  327.     public function getMinutes()
  328.     {
  329.         return $this->minutes;
  330.     }
  331.     /**
  332.      * Set source
  333.      *
  334.      * @param string $source
  335.      * @return Video
  336.      */
  337.     public function setSource($source)
  338.     {
  339.         $this->source = $source;
  340.         return $this;
  341.     }
  342.     /**
  343.      * Get source
  344.      *
  345.      * @return string
  346.      */
  347.     public function getSource()
  348.     {
  349.         return $this->source;
  350.     }
  351.     /**
  352.      * Set publicationDate
  353.      *
  354.      * @param \DateTime $publicationDate
  355.      * @return Video
  356.      */
  357.     public function setPublicationDate($publicationDate)
  358.     {
  359.         $this->publicationDate = $publicationDate;
  360.         return $this;
  361.     }
  362.     /**
  363.      * Get publicationDate
  364.      *
  365.      * @return \DateTime
  366.      */
  367.     public function getPublicationDate()
  368.     {
  369.         return $this->publicationDate;
  370.     }
  371.     /**
  372.      * Set isVaria
  373.      *
  374.      * @param boolean $isVaria
  375.      * @return Video
  376.      */
  377.     public function setIsVaria($isVaria)
  378.     {
  379.         $this->isVaria = $isVaria;
  380.         return $this;
  381.     }
  382.     /**
  383.      * Get isVaria
  384.      *
  385.      * @return boolean
  386.      */
  387.     public function getIsVaria()
  388.     {
  389.         return $this->isVaria;
  390.     }
  391.     /**
  392.      * Set user
  393.      *
  394.      * @param \Notaris\AdminBundle\Entity\User $user
  395.      * @return Video
  396.      */
  397.     public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
  398.     {
  399.         $this->user = $user;
  400.         return $this;
  401.     }
  402.     /**
  403.      * Get user
  404.      *
  405.      * @return \Notaris\AdminBundle\Entity\User
  406.      */
  407.     public function getUser()
  408.     {
  409.         return $this->user;
  410.     }
  411.     /**
  412.      * Set news
  413.      *
  414.      * @param \Notaris\AdminBundle\Entity\News $news
  415.      * @return Video
  416.      */
  417.     public function setNews(\Notaris\AdminBundle\Entity\News $news = null)
  418.     {
  419.         $this->news = $news;
  420.         return $this;
  421.     }
  422.     /**
  423.      * Get news
  424.      *
  425.      * @return \Notaris\AdminBundle\Entity\News
  426.      */
  427.     public function getNews()
  428.     {
  429.         return $this->news;
  430.     }
  431.     /**
  432.      * Set primarySubsite
  433.      *
  434.      * @param \Notaris\AdminBundle\Entity\Subsite $primarySubsite
  435.      * @return Video
  436.      */
  437.     public function setPrimarySubsite(\Notaris\AdminBundle\Entity\Subsite $primarySubsite = null)
  438.     {
  439.         $this->primarySubsite = $primarySubsite;
  440.         return $this;
  441.     }
  442.     /**
  443.      * Get primarySubsite
  444.      *
  445.      * @return \Notaris\AdminBundle\Entity\Subsite
  446.      */
  447.     public function getPrimarySubsite()
  448.     {
  449.         return $this->primarySubsite;
  450.     }
  451.     /**
  452.      * Add tags
  453.      *
  454.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  455.      * @return Video
  456.      */
  457.     public function addTag(\Notaris\AdminBundle\Entity\Tag $tags)
  458.     {
  459.         $this->tags[] = $tags;
  460.         return $this;
  461.     }
  462.     /**
  463.      * Remove tags
  464.      *
  465.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  466.      */
  467.     public function removeTag(\Notaris\AdminBundle\Entity\Tag $tags)
  468.     {
  469.         $this->tags->removeElement($tags);
  470.     }
  471.     /**
  472.      * Get tags
  473.      *
  474.      * @return \Doctrine\Common\Collections\Collection
  475.      */
  476.     public function getTags()
  477.     {
  478.         return $this->tags;
  479.     }
  480.     /**
  481.      * Set meta
  482.      *
  483.      * @param \Notaris\AdminBundle\Entity\Meta $meta
  484.      * @return Video
  485.      */
  486.     public function setMeta(\Notaris\AdminBundle\Entity\Meta $meta = null)
  487.     {
  488.         $this->meta = $meta;
  489.         return $this;
  490.     }
  491.     /**
  492.      * Get meta
  493.      *
  494.      * @return \Notaris\AdminBundle\Entity\Meta
  495.      */
  496.     public function getMeta()
  497.     {
  498.         return $this->meta;
  499.     }
  500.     /**
  501.      * Set isActive
  502.      *
  503.      * @param boolean $isActive
  504.      * @return Video
  505.      */
  506.     public function setIsActive($isActive)
  507.     {
  508.         $this->isActive = $isActive;
  509.         return $this;
  510.     }
  511.     /**
  512.      * Get isActive
  513.      *
  514.      * @return boolean
  515.      */
  516.     public function getIsActive()
  517.     {
  518.         return $this->isActive;
  519.     }
  520.     /**
  521.      * Add subsites
  522.      *
  523.      * @param \Notaris\AdminBundle\Entity\VideoSubsite $subsites
  524.      * @return Video
  525.      */
  526.     public function addSubsite(\Notaris\AdminBundle\Entity\VideoSubsite $subsites)
  527.     {
  528.         $this->subsites[] = $subsites;
  529.         return $this;
  530.     }
  531.     /**
  532.      * Remove subsites
  533.      *
  534.      * @param \Notaris\AdminBundle\Entity\VideoSubsite $subsites
  535.      */
  536.     public function removeSubsite(\Notaris\AdminBundle\Entity\VideoSubsite $subsites)
  537.     {
  538.         $this->subsites->removeElement($subsites);
  539.     }
  540.     /**
  541.      * Get subsites
  542.      *
  543.      * @return \Doctrine\Common\Collections\Collection
  544.      */
  545.     public function getSubsites()
  546.     {
  547.         $activeSubsites = [];
  548.         foreach ($this->subsites as $sub){
  549.             if($sub->getSubsite()->getIsActive()){
  550.                 $activeSubsites[] = $sub;
  551.             }
  552.         }
  553.         return $activeSubsites;
  554.     }
  555.     /**
  556.      * Set asset
  557.      *
  558.      * @param \Notaris\AdminBundle\Entity\Asset $asset
  559.      * @return Video
  560.      */
  561.     public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
  562.     {
  563.         $this->asset = $asset;
  564.         return $this;
  565.     }
  566.     /**
  567.      * Get asset
  568.      *
  569.      * @return \Notaris\AdminBundle\Entity\Asset
  570.      */
  571.     public function getAsset()
  572.     {
  573.         return $this->asset;
  574.     }
  575.     /**
  576.      * Set isVariaPrimary
  577.      *
  578.      * @param boolean $isVariaPrimary
  579.      * @return Video
  580.      */
  581.     public function setIsVariaPrimary($isVariaPrimary)
  582.     {
  583.         $this->isVariaPrimary = $isVariaPrimary;
  584.         return $this;
  585.     }
  586.     /**
  587.      * Get isVariaPrimary
  588.      *
  589.      * @return boolean
  590.      */
  591.     public function getIsVariaPrimary()
  592.     {
  593.         return $this->isVariaPrimary;
  594.     }
  595.     /**
  596.      * Set variaPosition
  597.      *
  598.      * @param integer $variaPosition
  599.      * @return Video
  600.      */
  601.     public function setVariaPosition($variaPosition)
  602.     {
  603.         $this->variaPosition = $variaPosition;
  604.         return $this;
  605.     }
  606.     /**
  607.      * Get variaPosition
  608.      *
  609.      * @return integer
  610.      */
  611.     public function getVariaPosition()
  612.     {
  613.         return $this->variaPosition;
  614.     }
  615.     /**
  616.      * Set countClicked
  617.      *
  618.      * @param integer $countClicked
  619.      * @return Video
  620.      */
  621.     public function setCountClicked($countClicked)
  622.     {
  623.         $this->countClicked = $countClicked;
  624.         return $this;
  625.     }
  626.     /**
  627.      * Get countClicked
  628.      *
  629.      * @return integer
  630.      */
  631.     public function getCountClicked()
  632.     {
  633.         return $this->countClicked;
  634.     }
  635.     /**
  636.      * Add category
  637.      *
  638.      * @param \Notaris\AdminBundle\Entity\IzimiCategory $category
  639.      *
  640.      * @return Video
  641.      */
  642.     public function addCategory(\Notaris\AdminBundle\Entity\IzimiCategory $category)
  643.     {
  644.         $this->categories[] = $category;
  645.         return $this;
  646.     }
  647.     /**
  648.      * Remove category
  649.      *
  650.      * @param \Notaris\AdminBundle\Entity\IzimiCategory $category
  651.      */
  652.     public function removeCategory(\Notaris\AdminBundle\Entity\IzimiCategory $category)
  653.     {
  654.         $this->categories->removeElement($category);
  655.     }
  656.     /**
  657.      * Get categories
  658.      *
  659.      * @return \Doctrine\Common\Collections\Collection
  660.      */
  661.     public function getCategories()
  662.     {
  663.         return $this->categories;
  664.     }
  665.     /**
  666.      * Set isIzimi
  667.      *
  668.      * @param boolean $isIzimi
  669.      * @return Video
  670.      */
  671.     public function setIsIzimi(bool $isIzimi)
  672.     {
  673.         $this->isIzimi = $isIzimi;
  674.         return $this;
  675.     }
  676.     /**
  677.      * Get isIzimi
  678.      *
  679.      * @return boolean
  680.      */
  681.     public function getIsIzimi()
  682.     {
  683.         return $this->isIzimi;
  684.     }
  685. }