src/Entity/Media/Video.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Media;
  3. use App\Entity\Educational\Lesson\Exercise\ObjectExercise;
  4. use App\Model\TimestampableTrait;
  5. use Bo\DomainBundle\Entity\SubChapterDomain;
  6. use Bo\MainBundle\Entity\Comment;
  7. use Bo\MainBundle\Entity\PublishableTrait;
  8. use Bo\MainBundle\Model\Publishable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. use App\Entity\Educational\SubChapterDomainVideo;
  14. /**
  15.  * Bo\MediaBundle\Entity\Video
  16.  *
  17.  * @ORM\Table(name="Video")
  18.  * @ORM\Entity()
  19.  * @ORM\HasLifecycleCallbacks()
  20.  */
  21. class Video //implements WorkListTable
  22. {
  23.     use TimestampableTrait;
  24.     //use HideableTrait;
  25.     const CONTENT_TYPE = 1;
  26.     const CONTENT_NAME = 'Video';
  27.     /**
  28.      * @var integer
  29.      *subChapterDomainsVideo
  30.      * @ORM\Column(name="id", type="integer")
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      */
  34.     private $id;
  35.     /*
  36.      * @ORM\ManyToOne(targetEntity="\Bo\WorkListBundle\Entity\Notion", inversedBy="videos")
  37.      * @ORM\JoinColumn(name="notion_id", referencedColumnName="id")
  38.      */
  39.     private $notion;
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="filename", type="string", length=255,nullable=true)
  44.      */
  45.     private $filename;
  46.     /**
  47.      * @var string $vimeoFile
  48.      *
  49.      * @ORM\Column(name="vimeo_file", type="string", length=255, nullable=true)
  50.      */
  51.     private $vimeoFile;
  52.     /**
  53.      * @var string
  54.      *
  55.      * @ORM\Column(name="video_id", type="string", length=255, nullable=true)
  56.      */
  57.     private $videoId;
  58.     /**
  59.      * @var string
  60.      *
  61.      * @ORM\Column(name="vimeo_id", type="string", length=255, nullable=true)
  62.      */
  63.     private $vimeoId;
  64.     /**
  65.      * @var string
  66.      *
  67.      * @ORM\Column(name="picture", type="string", length=255, nullable=true)
  68.      */
  69.     private $picture;
  70.     /**
  71.      * @var string $title
  72.      *
  73.      * @ORM\Column(name="title", type="string", length=255)
  74.      *
  75.      */
  76.     private $title;
  77.     /**
  78.      * @var string $description
  79.      *
  80.      * @ORM\Column(name="description", type="text", nullable=true)
  81.      */
  82.     private $description;
  83.     /**
  84.      * @var string $description
  85.      *
  86.      * @ORM\Column(name="correction", type="text", nullable=true)
  87.      */
  88.     private $correction;
  89.     /**
  90.      * @var string $description
  91.      *
  92.      * @ORM\Column(name="transcription", type="text", nullable=true)
  93.      */
  94.     private $transcription;
  95.     /**
  96.      * @var integer $position
  97.      *
  98.      * @ORM\Column(name="position", type="integer",nullable=true)
  99.      *
  100.      */
  101.     private $position;
  102.     /**
  103.      * @var integer $duration
  104.      *
  105.      * @ORM\Column(name="duration", type="integer",nullable=true)
  106.      *
  107.      */
  108.     private $duration;
  109.     /**
  110.      * @var integer $poster
  111.      *
  112.      * @ORM\Column(name="poster", type="string", length=255, nullable=true)
  113.      */
  114.     private $poster;
  115.     /**
  116.      * @var integer $pictureMobileId
  117.      *
  118.      * @ORM\Column(name="picture_mobile_id", type="integer", nullable=true)
  119.      */
  120.     private $pictureMobileId;
  121.     /**
  122.      * @var boolean $visibleForAll
  123.      *
  124.      * @ORM\Column(name="visible_for_all", type="boolean")
  125.      */
  126.     private $visibleForAll = false;
  127.     /**
  128.      * @var String $AnswersQuestion
  129.      * @ORM\Column(name="answers_question",type="text",nullable=true)
  130.      */
  131.     private $AnswersQuestion;
  132.     /**
  133.      * @var String $Resume
  134.      * @ORM\Column(name="resume",type="text",nullable=true)
  135.      */
  136.     private $resume;
  137.     /**
  138.      * @var string $title
  139.      *
  140.      * @ORM\Column(name="title_youtube", type="string", length=255,nullable=true)
  141.      *
  142.      */
  143.     private $titleYoutube;
  144.     /**
  145.      * @var boolean
  146.      *
  147.      * @ORM\Column(type="boolean")
  148.      */
  149.     private $published = false;
  150.     /**
  151.      * @var integer
  152.      *
  153.      * @ORM\Column(name="weight", type="integer", nullable=true, options={"unsigned"=true, "default"=0})
  154.      */
  155.     private $weight;
  156.     /**
  157.      * @var string
  158.      *
  159.      * @ORM\Column(name="caption", type="text",nullable=true)
  160.      *
  161.      */
  162.     private $caption;
  163.     /**
  164.      * @Gedmo\Slug(fields={"title","id"}, updatable=true)
  165.      * @ORM\Column(length=128, unique=true)
  166.      */
  167.     private $slug;
  168.     /**
  169.      * @var
  170.      * @ORM\Column(name="duration_youtube", type="text",nullable=true)
  171.      */
  172.     private $durationYoutube;
  173.     /**
  174.      * @var
  175.      * @ORM\Column(name="publish_date_youtube", type="text",nullable=true)
  176.      */
  177.     private $publishDateYoutube;
  178.     /**
  179.      * @var string
  180.      * @ORM\Column(name="meta_description",type="string",length=255,nullable=true)
  181.      */
  182.     private $metaDescription;
  183.     /**
  184.      * @var string
  185.      * @ORM\Column(name="transcript",type="string",nullable=true)
  186.      */
  187.     private $transcript;
  188.     /**
  189.      * @var string
  190.      * @ORM\Column(name="transcript_auto",type="string",nullable=true)
  191.      */
  192.     private $transcriptAuto;
  193.     private $transcriptFile;
  194.     /************************************************** Association ********************************************************/
  195.     /**
  196.      * @var $subchapters
  197.      * @ORM\OneToMany(targetEntity=SubChapterDomainVideo::class,mappedBy="video",cascade={"remove"})
  198.      */
  199.     private $subChapterDomainsVideo;
  200.     /*
  201.      * @var $exercises
  202.      * @ORM\ManyToMany(targetEntity="\Bo\MediaBundle\Entity\Tags" , inversedBy="videos", cascade={"remove"})
  203.      * @ORM\JoinTable(name="lnk_video_tags")
  204.      */
  205.     private $tags;
  206.     /*
  207.      * @var ArrayCollection
  208.      * @ORM\ManyToMany(targetEntity="Bo\MainBundle\Entity\Comment", cascade={"persist"})
  209.      * @ORM\OrderBy({"created" = "DESC"})
  210.      * @deprecated
  211.      */
  212.     private $comments;
  213.     /**
  214.      * @var string $linkKumulus
  215.      *
  216.      * @ORM\Column(name="link_kumulus", type="string", length=255, nullable=true)
  217.      */
  218.     private $linkKumulus;
  219.     /************************************************* Fin ***********************************************************/
  220.     /**
  221.      * Return all mobile pictures values
  222.      * NOTE : the index is the ID of the picture do note change or remove !
  223.      * @return array
  224.      */
  225.     public static function getMobilePictures()
  226.     {
  227.         $mobilePictures = array_flip([
  228.             1 => 'Adeline-PC.png',
  229.             2 => 'Alain-HG.png',
  230.             3 => 'Alexandre-Anglais.png',
  231.             4 => 'Alexis-HG.png',
  232.             5 => 'Ana-espagnol.png',
  233.             6 => 'Anne-laure-Maths.png',
  234.             7 => 'Anne-Maths.png',
  235.             8 => 'Anne-Sophie-SVT.png',
  236.             9 => 'Antoine-Maths.png',
  237.             10 => 'Arnaud-HG.png',
  238.             11 => 'Benjamin-SVT.png',
  239.             12 => 'Benoit-Philo.png',
  240.             13 => 'Berenice-Francais.png',
  241.             14 => 'Bertrand-Maths.png',
  242.             15 => 'Camille-Allemand.png',
  243.             16 => 'Caroline-Francais.png',
  244.             17 => 'Cedric-Anglais.png',
  245.             18 => 'Cedric-Geopo.png',
  246.             19 => 'CharlotteB-Francais.png',
  247.             20 => 'CharlotteG-Francais.png',
  248.             21 => 'Damien-HG.png',
  249.             22 => 'Elodie-Francais.png',
  250.             23 => 'Emmanuel-Anglais.png',
  251.             24 => 'Francoise-Philo.png',
  252.             25 => 'Guillaume-PC.png',
  253.             26 => 'Hugo-HG.png',
  254.             27 => 'Jean-Francois-Maths.png',
  255.             28 => 'Joaquim-Espagnol.png',
  256.             29 => 'Juliette-Francais.png',
  257.             30 => 'Linda-PFEG.png',
  258.             31 => 'Marie-Anne-Maths.png',
  259.             32 => 'Marielle-Maths.png',
  260.             33 => 'Marie-PC.png',
  261.             34 => 'Maxime-SES.png',
  262.             35 => 'Melanie-Francais.png',
  263.             36 => 'Nolwenn-SES.png',
  264.             37 => 'Olivier-Maths.png',
  265.             38 => 'Ombeline-Anglais.png',
  266.             39 => 'Ophelie-SES.png',
  267.             40 => 'Pablo-SI.png',
  268.             41 => 'PierreB-PC.png',
  269.             42 => 'PierreS-Philo.png',
  270.             43 => 'Sarra-PC.png',
  271.             44 => 'Simon-PC.png',
  272.             45 => 'Sonia-Maths.png',
  273.             46 => 'Stephanie-SVT.png',
  274.             47 => 'Thomas-SVT.png',
  275.             48 => 'Valentine-FLE.png',
  276.             49 => 'Daphne-HG.png',
  277.             50 => 'Alexandra-Espagnol.png',
  278.             51 => 'Maud-Espagnol.png',
  279.             52 => 'Melanie-Anglais.png',
  280.             53 => 'Eudoxie-Maths.png',
  281.             54 => 'Helene-Geopo.png',
  282.             55 => 'CharlotteF-fr.png',
  283.             56 => 'Sandrine-SVT.png',
  284.             57 => 'Emilien-SVT.png',
  285.             58 => 'Pierre-Derrycke.jpg',
  286.             59 => 'Aure-Elise.jpg',
  287.             60 => 'Anais-Maths.png',
  288.             61 => 'Alexandra-Maths.png',
  289.             62 => 'Jean-Marie-Geopo.png',
  290.             63 => 'Maud-Français.png',
  291.             64 => 'Veronique-PC.png',
  292.             65 => 'Agnes-SVT.png',
  293.             66 => 'Betty-EMC.png',
  294.             67 => 'Guillaume-maths.png',
  295.             68 => 'Jeanne-HG.png',
  296.             69 => 'Miguel-SES.png',
  297.             70 => 'Francois-maths.png',
  298.             71 => 'Axel-LLCE.jpg',
  299.             72 => 'DamienL-Methode.png',
  300.             73 => 'Francky.png',
  301.             74 => 'Marion-SES.png',
  302.         ]);
  303.         asort($mobilePictures);
  304.         return $mobilePictures;
  305.     }
  306.     /**
  307.      * Video constructor.
  308.      */
  309.     public function __construct()
  310.     {
  311.         $this->subChapterDomainsVideo = new ArrayCollection();
  312.         $this->tags = new ArrayCollection();
  313.         $this->comments = new ArrayCollection();
  314.     }
  315.     /**
  316.      * Get id
  317.      *
  318.      * @return integer
  319.      */
  320.     public function getId()
  321.     {
  322.         return $this->id;
  323.     }
  324.     /**
  325.      * @param $id
  326.      */
  327.     public function setId($id)
  328.     {
  329.         $this->id = $id;
  330.     }
  331.     /**
  332.      * @return ArrayCollection
  333.      */
  334.     public function getComments()
  335.     {
  336.         return $this->comments;
  337.     }
  338.     /**
  339.      * @param ArrayCollection $comments
  340.      */
  341.     public function setComments(ArrayCollection $comments)
  342.     {
  343.         $this->comments = $comments;
  344.     }
  345.     /**
  346.      * @param Comment $comment
  347.      */
  348.     public function addComment($comment)
  349.     {
  350.         if (!$this->comments->contains($comment)) {
  351.             $this->comments->add($comment);
  352.         }
  353.     }
  354.     /**
  355.      * @param Comment $comment
  356.      */
  357.     public function removeComment($comment)
  358.     {
  359.         if ($this->comments->contains($comment)) {
  360.             $this->comments->removeElement($comment);
  361.         }
  362.     }
  363.     /**
  364.      * @return String
  365.      */
  366.     public function getResume()
  367.     {
  368.         return $this->resume;
  369.     }
  370.     /**
  371.      * @param String $resume
  372.      */
  373.     public function setResume($resume)
  374.     {
  375.         $this->resume = $resume;
  376.     }
  377.     /**
  378.      * @return mixed
  379.      */
  380.     public function getSubChapterDomainsVideo()
  381.     {
  382.         return $this->subChapterDomainsVideo;
  383.     }
  384.     /**
  385.      * @param mixed $subChapterDomainsVideo
  386.      */
  387.     public function setSubChapterDomainsVideo($subChapterDomainsVideo)
  388.     {
  389.         $this->subChapterDomainsVideo = $subChapterDomainsVideo;
  390.     }
  391.     /**
  392.      * @param mixed $subChapterDomainsVideo
  393.      */
  394.     public function addSubChapterDomainsVideo($subChapterDomainsVideo)
  395.     {
  396.         $this->subChapterDomainsVideo[] = $subChapterDomainsVideo;
  397.     }
  398.     /**
  399.      * Set filename
  400.      *
  401.      * @param string $filename
  402.      */
  403.     public function setFilename($filename)
  404.     {
  405.         $this->filename = $filename;
  406.     }
  407.     /**
  408.      * Get filename
  409.      *
  410.      * @param array $options
  411.      * @return string
  412.      */
  413.     public function getFilename(array $options = array())
  414.     {
  415.         return $this->filename;
  416.     }
  417.     /**
  418.      * Set vimeoFile
  419.      *
  420.      * @param string $vimeoFile
  421.      */
  422.     public function setVimeoFile($vimeoFile)
  423.     {
  424.         $this->vimeoFile = $vimeoFile;
  425.     }
  426.     /**
  427.      * Get vimeoFile
  428.      *
  429.      * @return string
  430.      */
  431.     public function getVimeoFile()
  432.     {
  433.         return $this->vimeoFile;
  434.     }
  435.     public function getVideoMp4(array $options = array())
  436.     {
  437.         return $this->filename . '.mp4';
  438.     }
  439.     /**
  440.      * Set title
  441.      *
  442.      * @param string $title
  443.      */
  444.     public function setTitle($title)
  445.     {
  446.         $this->title = $title;
  447.     }
  448.     /**
  449.      * Get title
  450.      *
  451.      * @return string
  452.      */
  453.     public function getTitle()
  454.     {
  455.         return $this->title;
  456.     }
  457.     /**
  458.      * Set description
  459.      *
  460.      * @param string $description
  461.      */
  462.     public function setDescription($description)
  463.     {
  464.         $this->description = $description;
  465.     }
  466.     /**
  467.      * Get description
  468.      *
  469.      * @return string
  470.      */
  471.     public function getDescription()
  472.     {
  473.         return $this->description;
  474.     }
  475.     /**
  476.      * Set position
  477.      *
  478.      * @param integer $position
  479.      */
  480.     public function setPosition($position)
  481.     {
  482.         $this->position = $position;
  483.     }
  484.     /**
  485.      * Get position
  486.      *
  487.      * @return integer
  488.      */
  489.     public function getPosition()
  490.     {
  491.         return $this->position;
  492.     }
  493.     /**
  494.      * Set duration
  495.      *
  496.      * @param integer $duration
  497.      */
  498.     public function setDuration($duration)
  499.     {
  500.         $this->duration = $duration;
  501.     }
  502.     /**
  503.      * Get duration
  504.      *
  505.      * @return integer
  506.      */
  507.     public function getDuration()
  508.     {
  509.         return $this->duration;
  510.     }
  511.     /**
  512.      * Set poster
  513.      *
  514.      * @param string $poster
  515.      */
  516.     public function setPoster($poster)
  517.     {
  518.         $this->poster = $poster;
  519.     }
  520.     /**
  521.      * Get poster
  522.      *
  523.      * @return string
  524.      */
  525.     public function getPoster()
  526.     {
  527.         return $this->poster;
  528.     }
  529.     /**
  530.      * @return integer
  531.      */
  532.     public function getPictureMobileId()
  533.     {
  534.         return $this->pictureMobileId;
  535.     }
  536.     /**
  537.      * @param integer $pictureMobileId
  538.      */
  539.     public function setPictureMobileId($pictureMobileId)
  540.     {
  541.         $this->pictureMobileId = $pictureMobileId;
  542.     }
  543.     /**
  544.      * Set visibleForAll
  545.      *
  546.      * @param boolean $visibleForAll
  547.      */
  548.     public function setVisibleForAll($visibleForAll)
  549.     {
  550.         $this->visibleForAll = $visibleForAll;
  551.     }
  552.     /**
  553.      * is visibleForAll
  554.      *
  555.      * @return boolean
  556.      */
  557.     public function isVisibleForAll()
  558.     {
  559.         return $this->visibleForAll;
  560.     }
  561.     /**
  562.      * Return human friendly duration
  563.      * @return string
  564.      */
  565.     public function getHumanDuration()
  566.     {
  567.         $duration = $this->getDuration();
  568.         $format = '%d:%s';
  569.         $minutes = 0;
  570.         $seconds = 0;
  571.         if ($duration < 60) {
  572.             $seconds = $duration;
  573.         } else {
  574.             $seconds = floor($duration % 60);
  575.             $minutes = floor($duration / 60);
  576.         }
  577.         $seconds = $seconds > 9 ? $seconds : '0' . $seconds;
  578.         return sprintf($format, $minutes, $seconds);
  579.     }
  580.     public function __toString()
  581.     {
  582.         return $this->getTitle();
  583.     }
  584.     /**
  585.      * @return String
  586.      */
  587.     public function getAnswersQuestion()
  588.     {
  589.         return $this->AnswersQuestion;
  590.     }
  591.     /**
  592.      * @param String $AnswersQuestion
  593.      */
  594.     public function setAnswersQuestion($AnswersQuestion)
  595.     {
  596.         $this->AnswersQuestion = $AnswersQuestion;
  597.     }
  598.     /**
  599.      * @return string
  600.      */
  601.     public function getVideoId()
  602.     {
  603.         return $this->videoId;
  604.     }
  605.     /**
  606.      * @param string $videoId
  607.      */
  608.     public function setVideoId($videoId)
  609.     {
  610.         $this->videoId = $videoId;
  611.     }
  612.     /**
  613.      * @return string
  614.      */
  615.     public function getVimeoId(): ?string
  616.     {
  617.         return $this->vimeoId;
  618.     }
  619.     /**
  620.      * @param string $vimeoId
  621.      */
  622.     public function setVimeoId(string $vimeoId): void
  623.     {
  624.         $this->vimeoId = $vimeoId;
  625.     }
  626.     /**
  627.      * @return string
  628.      */
  629.     public function getPicture()
  630.     {
  631.         return $this->picture;
  632.     }
  633.     /**
  634.      * @param string $picture
  635.      */
  636.     public function setPicture($picture)
  637.     {
  638.         $this->picture = $picture;
  639.     }
  640.     /**
  641.      * @return boolean
  642.      */
  643.     public function isPublished()
  644.     {
  645.         return $this->published;
  646.     }
  647.     /**
  648.      * @param boolean $published
  649.      */
  650.     public function setPublished($published)
  651.     {
  652.         $this->published = $published;
  653.     }
  654.     /**
  655.      * @return int
  656.      */
  657.     public function getWeight()
  658.     {
  659.         return $this->weight;
  660.     }
  661.     /**
  662.      * @param int $weight
  663.      */
  664.     public function setWeight($weight)
  665.     {
  666.         $this->weight = $weight;
  667.     }
  668.     /**
  669.      * @return string
  670.      */
  671.     public function getCaption()
  672.     {
  673.         return $this->caption;
  674.     }
  675.     /**
  676.      * @param string $caption
  677.      */
  678.     public function setCaption($caption)
  679.     {
  680.         $this->caption = $caption;
  681.     }
  682.     /**
  683.      * @return mixed
  684.      */
  685.     public function getSlug()
  686.     {
  687.         return $this->slug;
  688.     }
  689.     /**
  690.      * @param mixed $slug
  691.      */
  692.     public function setSlug($slug)
  693.     {
  694.         $this->slug = $slug;
  695.     }
  696.     /**
  697.      * @return HomeWork
  698.      */
  699.     public function getExercises()
  700.     {
  701.         return $this->exercises;
  702.     }
  703.     /**
  704.      * @param HomeWork $exercises
  705.      */
  706.     public function setExercises($exercises)
  707.     {
  708.         $this->exercises = $exercises;
  709.     }
  710.     /**
  711.      * @param HomeWork $exercises
  712.      */
  713.     public function addExercises($exercises)
  714.     {
  715.         $this->exercises[] = $exercises;
  716.     }
  717.     public function hasExercises()
  718.     {
  719.         return 0 < count($this->exercises);
  720.     }
  721.     /**
  722.      * @return string
  723.      */
  724.     public function getTitleYoutube()
  725.     {
  726.         return $this->titleYoutube;
  727.     }
  728.     /**
  729.      * @param string $titleYoutube
  730.      */
  731.     public function setTitleYoutube($titleYoutube)
  732.     {
  733.         $this->titleYoutube = $titleYoutube;
  734.     }
  735.     /**
  736.      * @return mixed
  737.      */
  738.     public function getNotion()
  739.     {
  740.         return $this->notion;
  741.     }
  742.     /**
  743.      * @param mixed $notion
  744.      */
  745.     public function setNotion($notion)
  746.     {
  747.         $this->notion = $notion;
  748.     }
  749.     /**
  750.      * @return mixed
  751.      */
  752.     public function getTags()
  753.     {
  754.         return $this->tags;
  755.     }
  756.     /**
  757.      * @param mixed $tags
  758.      */
  759.     public function setTags($tags)
  760.     {
  761.         $this->tags = $tags;
  762.     }
  763.     /**
  764.      * @param mixed $tags
  765.      */
  766.     public function addTags($tags)
  767.     {
  768.         $verif = false;
  769.         if (!$this->tags->isEmpty()) {
  770.             foreach ($this->tags as $tmp) {
  771.                 if ($tmp->getId() == $tags->getId()) {
  772.                     $verif = true;
  773.                 }
  774.             }
  775.         }
  776.         if (!$verif) {
  777.             $this->tags[] = $tags;
  778.             $tags->addVideo($this);
  779.         }
  780.     }
  781.     public function isSubDomainChapter($idSubchapter)
  782.     {
  783.         foreach ($this->getSubChapterDomains() as $gsd) {
  784.             if ($gsd->getId() == $idSubchapter) {
  785.                 return true;
  786.             }
  787.         }
  788.         return false;
  789.     }
  790.     /**
  791.      * @return mixed
  792.      */
  793.     public function getDurationYoutube()
  794.     {
  795.         if ($this->durationYoutube != '') {
  796.             return $this->durationYoutube;
  797.         } else {
  798.             return '  n/a ';
  799.         }
  800.     }
  801.     /**
  802.      * @param mixed $durationYoutube
  803.      */
  804.     public function setDurationYoutube($durationYoutube)
  805.     {
  806.         $this->durationYoutube = $durationYoutube;
  807.     }
  808.     /**
  809.      * @return mixed
  810.      */
  811.     public function getPublishDateYoutube()
  812.     {
  813.         return $this->publishDateYoutube;
  814.     }
  815.     /**
  816.      * @param mixed $publishDateYoutube
  817.      */
  818.     public function setPublishDateYoutube($publishDateYoutube)
  819.     {
  820.         $this->publishDateYoutube = $publishDateYoutube;
  821.     }
  822.     /* public function getVideoSubchapterDomainByDomainId($domainId)
  823.     {
  824.         if(empty($this->subChapterDomains) || empty($domainId))
  825.         {
  826.             return array();
  827.         }
  828.         foreach($this->subChapterDomains as $sub)
  829.         {
  830.             if($sub->getDomain()->getId() == $domainId)
  831.             {
  832.                 return $sub->getVideos();
  833.             }
  834.         }
  835.     }
  836.     */
  837.     /********************** Interface *************************/
  838.     public function getTypeWI()
  839.     {
  840.         // TODO: Implement getTypeWI() method.
  841.     }
  842.     public function getTitleWI()
  843.     {
  844.         // TODO: Implement getTitleWI() method.
  845.     }
  846.     /**
  847.      * Get visibleForAll
  848.      *
  849.      * @return boolean
  850.      */
  851.     public function getVisibleForAll()
  852.     {
  853.         return $this->visibleForAll;
  854.     }
  855.     /**
  856.      * Get published
  857.      *
  858.      * @return boolean
  859.      */
  860.     public function getPublished()
  861.     {
  862.         return $this->published;
  863.     }
  864.     /**
  865.      * Add exercises
  866.      *
  867.      * @param \Bo\ExerciseBundle\Entity\ObjectExercise $exercises
  868.      * @return Video
  869.      */
  870.     public function addExercise(ObjectExercise $exercises)
  871.     {
  872.         $this->exercises[] = $exercises;
  873.         return $this;
  874.     }
  875.     /**
  876.      * Remove exercises
  877.      *
  878.      * @param \Bo\ExerciseBundle\Entity\ObjectExercise $exercises
  879.      */
  880.     public function removeExercise(ObjectExercise $exercises)
  881.     {
  882.         $this->exercises->removeElement($exercises);
  883.     }
  884.     /**
  885.      * Add tags
  886.      *
  887.      * @param \Bo\MediaBundle\Entity\Tags $tags
  888.      * @return Video
  889.      */
  890.     public function addTag( $tags)
  891.     {
  892.         $this->tags[] = $tags;
  893.         return $this;
  894.     }
  895.     /**
  896.      * Remove tags
  897.      *
  898.      * @param \Bo\MediaBundle\Entity\Tags $tags
  899.      */
  900.     public function removeTag($tags)
  901.     {
  902.         $this->tags->removeElement($tags);
  903.     }
  904.     public function getMinutes()
  905.     {
  906.         return ceil($this->duration / 60);
  907.     }
  908.     /**
  909.      * @return string
  910.      */
  911.     public function getMetaDescription()
  912.     {
  913.         return $this->metaDescription;
  914.     }
  915.     /**
  916.      * @param string $metaDescription
  917.      */
  918.     public function setMetaDescription($metaDescription)
  919.     {
  920.         $this->metaDescription = $metaDescription;
  921.     }
  922.     public function getMaxResPicture()
  923.     {
  924.         if (!$this->getVideoId()) {
  925.             return $this->getPicture();
  926.         }
  927.         return 'https://i.ytimg.com/vi/' . $this->getVideoId() . '/maxresdefault.jpg';
  928.     }
  929.     public function getMQPicture()
  930.     {
  931.         if (!$this->getVideoId()) {
  932.             return $this->getPicture();
  933.         }
  934.         return 'https://i.ytimg.com/vi/' . $this->getVideoId() . '/mqdefault.jpg';
  935.     }
  936.     /**
  937.      * @return mixed
  938.      */
  939.     public function getActor()
  940.     {
  941.         return $this->actor;
  942.     }
  943.     /**
  944.      * @param mixed $actor
  945.      */
  946.     public function setActor($actor)
  947.     {
  948.         $this->actor = $actor;
  949.     }
  950.     /**
  951.      * @return string
  952.      */
  953.     public function getTranscript()
  954.     {
  955.         return $this->transcript;
  956.     }
  957.     /**
  958.      * @param ?string $transcript
  959.      */
  960.     public function setTranscript(?string $transcript): void
  961.     {
  962.         $this->transcript = $transcript;
  963.     }
  964.     /**
  965.      * @return mixed
  966.      */
  967.     public function getTranscriptFile()
  968.     {
  969.         return $this->transcriptFile;
  970.     }
  971.     /**
  972.      * @param mixed $transcriptFile
  973.      */
  974.     public function setTranscriptFile($transcriptFile): void
  975.     {
  976.         $this->transcriptFile = $transcriptFile;
  977.     }
  978.     public function getAbsolutePath()
  979.     {
  980.         return null === $this->transcript ? null : sprintf("%s/%s", $this->getUploadRootDir(), $this->transcript);
  981.     }
  982.     public function getWebPath()
  983.     {
  984.         return null === $this->transcript ? null : sprintf("/%s/%s", $this->getUploadDir(), $this->transcript);
  985.     }
  986.     protected function getUploadRootDir()
  987.     {
  988.         // le chemin absolu du répertoire où les documents uploadés doivent être sauvegardés
  989.         return __DIR__ . '/../../../../public/' . $this->getUploadDir();
  990.     }
  991.     protected function getUploadDir()
  992.     {
  993.         // on se débarrasse de « __DIR__ » afin de ne pas avoir de problème lorsqu'on affiche
  994.         // le document/image dans la vue.
  995.         return 'gatewayImages/front/videos/transcripts/';
  996.     }
  997.     /**
  998.      * @ORM\PrePersist
  999.      * @ORM\PreUpdate
  1000.      */
  1001.     public function PreUpdate()
  1002.     {
  1003.         if (null !== $this->transcriptFile) {
  1004.             $this->transcript = sha1(uniqid(mt_rand(), true)) . '.' . $this->transcriptFile->guessExtension();
  1005.         }
  1006.     }
  1007.     /**
  1008.      * @ORM\PostPersist
  1009.      * @ORM\PostUpdate
  1010.      */
  1011.     public function PostUpdate()
  1012.     {
  1013.         if (null === $this->transcriptFile) {
  1014.             return;
  1015.         }
  1016.         // s'il y a une erreur lors du déplacement du fichier, une exception
  1017.         // va automatiquement être lancée par la méthode move(). Cela va empêcher
  1018.         // proprement l'entité d'être persistée dans la base de données si
  1019.         // erreur il y a
  1020.         if (!is_dir($this->getUploadRootDir())) {
  1021.             mkdir($this->getUploadRootDir(), '0777', true);
  1022.         }
  1023.         $this->transcriptFile->move($this->getUploadRootDir(), $this->transcript);
  1024.         unset($this->transcriptFile);
  1025.     }
  1026.     /**
  1027.      * @return mixed
  1028.      */
  1029.     public function __toArray()
  1030.     {
  1031.         $data['id'] = $this->getId();
  1032.         $data['title'] = $this->getTitle();
  1033.         $data['description'] = str_replace(array('.', "\n", "\t", "\r"), '',strip_tags(html_entity_decode($this->getDescription())));
  1034.         $data['resume'] = str_replace(array('.', "\n", "\t", "\r"), '',strip_tags(html_entity_decode($this->getResume())));
  1035.         $data['poster'] = $this->getPoster() ? $this->getPoster() : $this->getPicture();
  1036.         $data['slug'] = $this->getSlug();
  1037.         return $data;
  1038.     }
  1039.     /**
  1040.      * @return string
  1041.      */
  1042.     public function getLinkKumulus()
  1043.     {
  1044.         return $this->linkKumulus;
  1045.     }
  1046.     /**
  1047.      * @param string $linkKumulus
  1048.      */
  1049.     public function setLinkKumulus($linkKumulus)
  1050.     {
  1051.         $this->linkKumulus = $linkKumulus;
  1052.     }
  1053.     public function getTranscriptAuto()
  1054.     {
  1055.         return $this->transcriptAuto;
  1056.     }
  1057.     public function setTranscriptAuto($transcriptAuto): void
  1058.     {
  1059.         $this->transcriptAuto = $transcriptAuto;
  1060.     }
  1061.     public function getCorrection(): ?string
  1062.     {
  1063.         return $this->correction;
  1064.     }
  1065.     public function setCorrection(string $correction): void
  1066.     {
  1067.         $this->correction = $correction;
  1068.     }
  1069.     public function getTranscription(): ?string
  1070.     {
  1071.         return $this->transcription;
  1072.     }
  1073.     public function setTranscription(string $transcription): void
  1074.     {
  1075.         $this->transcription = $transcription;
  1076.     }
  1077. }