src/Entity/Educational/Domain.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Educational;
  3. use App\Entity\Educational\Lesson\Exercise\StatementLine;
  4. use App\Entity\Educational\Lesson\WorkListNode;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. /**
  11.  * aba\DomainBundle\Entity\Domain
  12.  *
  13.  * @ORM\Table(name="admin_domain")
  14.  * @ORM\Entity(repositoryClass="App\Repository\Educational\DomainRepository")
  15.  */
  16. class Domain
  17. {
  18.     /**
  19.      * @var integer $id
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string $title
  28.      *
  29.      * @ORM\Column(name="title", type="string", length=255)     *
  30.      * @Assert\NotBlank()
  31.      */
  32.     private $title;
  33.     /**
  34.      * @var string $slug
  35.      *
  36.      * @ORM\Column(name="`online`", type="boolean")
  37.      *
  38.      */
  39.     private $online;
  40.     /**
  41.      * @var string $position
  42.      *
  43.      * @ORM\Column(name="position", type="integer")
  44.      *
  45.      */
  46.     private $position;
  47.     /**
  48.      * @var $slug
  49.      * @Gedmo\Slug(fields={"title"})
  50.      * @ORM\Column(name="slug",type="string",length=255)
  51.      */
  52.     private $slug;
  53.     /**
  54.      * @ORM\Column(name="speciality",type="boolean",nullable=true)
  55.      */
  56.     private $speciality;
  57.     /**
  58.      * @ORM\Column(name="missionExamProgram",type="boolean",options={"default":0})
  59.      */
  60.     private $missionExamProgram;
  61.     /**
  62.      * @var string
  63.      * @ORM\Column(name="picture", type="string", length=512, nullable=true)
  64.      */
  65.     private $picture;
  66.     /**
  67.      * @var integer $pictureMobileId
  68.      *
  69.      * @ORM\Column(name="picture_mobile_id", type="integer", nullable=true)
  70.      */
  71.     private $pictureMobileId;
  72.     /**
  73.      * @var string
  74.      *
  75.      * @ORM\Column(name="description", type="text", nullable=true)
  76.      */
  77.     private $description;
  78.     /**
  79.      * @var string
  80.      *
  81.      * @ORM\Column(name="metadescription", type="text", nullable=true)
  82.      */
  83.     private $metadescription;
  84.     /**
  85.      * @var string $fileIcon
  86.      *
  87.      * @ORM\Column(name="file_icon",type="string",length=255,nullable=true)
  88.      *
  89.      */
  90.     private $fileIcon;
  91.     /**************************** Association *********************************/
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity="Serie")
  94.      * @ORM\JoinColumn(name="serie_id",referencedColumnName="id")
  95.      */
  96.     private $serie;
  97.     /**
  98.      * @ORM\ManyToOne(targetEntity="Course",inversedBy="domains")
  99.      * @ORM\JoinColumn(name="course_id",referencedColumnName="id")
  100.      */
  101.     private $course;
  102.     /**
  103.      * @var Discipline $discipline
  104.      * @ORM\ManyToOne(targetEntity="Discipline",inversedBy="domain")
  105.      * @ORM\JoinColumn(name="disciplines_id",referencedColumnName="id")
  106.      * @ORM\OrderBy({"order" = "ASC"})
  107.      */
  108.     private $discipline;
  109.     /**
  110.      * @ORM\ManyToOne(targetEntity="Chapter", inversedBy="domains", cascade={"persist"}, fetch="LAZY")
  111.      * @ORM\JoinColumn(name="chapter_id",referencedColumnName="id")
  112.      * @ORM\OrderBy({"position" = "ASC"})
  113.      */
  114.     private $chapter;
  115.     /**
  116.      * @ORM\OneToMany(targetEntity="SubChapterDomain",mappedBy="domain",fetch="LAZY", cascade={"remove"})
  117.      * @ORM\OrderBy({"position" = "ASC"})
  118.      */
  119.     private $subChapterDomains;
  120.     /*
  121.      * @var StatementLine
  122.      * @ORM\ManyToMany(targetEntity="\Bo\ExerciseBundle\Entity\StatementLine",inversedBy="domains",cascade={"persist"})
  123.      * @ORM\JoinTable(name="lnk_statementlines_domains")
  124.      */
  125.     private $statementLines;
  126.     /*
  127.      * @ORM\OneToMany(targetEntity="\Bo\WorkListBundle\Entity\WorkList", mappedBy="domain")
  128.      * @ORM\OrderBy({"position" = "ASC"})
  129.      */
  130.     private $workList;
  131.     /**
  132.      * @ORM\OneToMany(targetEntity="App\Entity\Educational\Lesson\WorkListNode", mappedBy="domain")
  133.      * @ORM\OrderBy({"position" = "ASC"})
  134.      */
  135.     private $workListNode;
  136.     /*
  137.      * @ORM\OneToMany(targetEntity="\Bo\AdministratorsBundle\Entity\ValidateFlow", mappedBy="domain")
  138.      */
  139.     private $validateFlow;
  140.     /**************************** FIN ***********************************/
  141.     public function __construct()
  142.     {
  143.         $this->exercises = new ArrayCollection();
  144.         $this->subChapterDomains = new ArrayCollection();
  145.         $this->statementLines = new ArrayCollection();
  146.     }
  147.     /**
  148.      * @return int
  149.      */
  150.     public function getId()
  151.     {
  152.         return $this->id;
  153.     }
  154.     /**
  155.      * @return string
  156.      */
  157.     public function getTitle()
  158.     {
  159.         return $this->title;
  160.     }
  161.     /**
  162.      * @param string $title
  163.      */
  164.     public function setTitle($title)
  165.     {
  166.         $this->title = $title;
  167.     }
  168.     /**
  169.      * @return string
  170.      */
  171.     public function getOnline()
  172.     {
  173.         return $this->online;
  174.     }
  175.     /**
  176.      * @param string $online
  177.      */
  178.     public function setOnline($online)
  179.     {
  180.         $this->online = $online;
  181.     }
  182.     /**
  183.      * @return string
  184.      */
  185.     public function getPosition()
  186.     {
  187.         return $this->position;
  188.     }
  189.     /**
  190.      * @param string $position
  191.      */
  192.     public function setPosition($position)
  193.     {
  194.         $this->position = $position;
  195.     }
  196.     /**
  197.      * @return mixed
  198.      */
  199.     public function getSlug()
  200.     {
  201.         return $this->slug;
  202.     }
  203.     /**
  204.      * @param mixed $slug
  205.      */
  206.     public function setSlug($slug)
  207.     {
  208.         $this->slug = $slug;
  209.     }
  210.     /**
  211.      * @return mixed
  212.      */
  213.     public function getSerie()
  214.     {
  215.         return $this->serie;
  216.     }
  217.     /**
  218.      * @param mixed $serie
  219.      */
  220.     public function setSerie($serie)
  221.     {
  222.         $this->serie = $serie;
  223.     }
  224.     /**
  225.      * @return mixed
  226.      */
  227.     public function getCourse()
  228.     {
  229.         return $this->course;
  230.     }
  231.     /**
  232.      * @param mixed $course
  233.      */
  234.     public function setCourse($course)
  235.     {
  236.         $this->course = $course;
  237.     }
  238.     /**
  239.      * @return Discipline
  240.      */
  241.     public function getDiscipline()
  242.     {
  243.         return $this->discipline;
  244.     }
  245.     /**
  246.      * @param Discipline $discipline
  247.      */
  248.     public function setDiscipline($discipline)
  249.     {
  250.         $this->discipline = $discipline;
  251.     }
  252.     /**
  253.      * @return mixed
  254.      */
  255.     public function getChapter()
  256.     {
  257.         return $this->chapter;
  258.     }
  259.     /**
  260.      * @param mixed $chapter
  261.      */
  262.     public function setChapter($chapter)
  263.     {
  264.         $this->chapter = $chapter;
  265.     }
  266.     /**
  267.      * @return HomeWork
  268.      */
  269.     public function getExercises()
  270.     {
  271.         return $this->exercises;
  272.     }
  273.     /**
  274.      * @param HomeWork $exercises
  275.      */
  276.     public function addExercises($exercise)
  277.     {
  278.         $this->exercises[] = $exercise;
  279.         $exercise->addDomains($this);
  280.     }
  281.     public function addExercise($exercise)
  282.     {
  283.         if (!in_array($exercise, $this->exercises->toArray())) {
  284.             $this->addExercises($exercise);
  285.             return true;
  286.         }
  287.         return false;
  288.     }
  289.     public function getJson($type)
  290.     {
  291.         $json = array(
  292.             "title" => $this->chapter->getTitle(),
  293.             "id" => $this->chapter->getId(),
  294.             "domainId" => $this->id,
  295.         );
  296.         if ($type !== "exercise") {
  297.             foreach ($this->exercises as $exercise) {
  298.                 $json["exercises"][] = array("title" => $exercise->getTitle(), "id" => $exercise->getId());
  299.             }
  300.         }
  301.         return $json;
  302.     }
  303.     /**
  304.      * @return mixed
  305.      */
  306.     public function getSubChapterDomains()
  307.     {
  308.         return $this->subChapterDomains;
  309.     }
  310.     /**
  311.      * @param mixed $subChapterDomains
  312.      */
  313.     public function setSubChapterDomains($subChapterDomains)
  314.     {
  315.         $this->subChapterDomains = $subChapterDomains;
  316.     }
  317.     /**
  318.      * @param mixed $subChapterDomains
  319.      */
  320.     public function addSubChapterDomains($subChapterDomains)
  321.     {
  322.         $this->subChapterDomains[] = $subChapterDomains;
  323.     }
  324.     public function __toString()
  325.     {
  326.         return $this->course . ' - ' . $this->serie . ' - ' . $this->discipline . ' - ' . $this->chapter;
  327.     }
  328.     /**
  329.      * @return mixed
  330.      */
  331.     public function getSpeciality()
  332.     {
  333.         return $this->speciality;
  334.     }
  335.     /**
  336.      * @param mixed $speciality
  337.      */
  338.     public function setSpeciality($speciality)
  339.     {
  340.         $this->speciality = $speciality;
  341.     }
  342.     /**
  343.      * Add subChapterDomains
  344.      *
  345.      * @param \Bo\DomainBundle\Entity\SubChapterDomain $subChapterDomains
  346.      * @return Domain
  347.      */
  348.     public function addSubChapterDomain($subChapterDomains)
  349.     {
  350.         $this->subChapterDomains[] = $subChapterDomains;
  351.         return $this;
  352.     }
  353.     /**
  354.      * Remove subChapterDomains
  355.      *
  356.      * @param \Bo\DomainBundle\Entity\SubChapterDomain $subChapterDomains
  357.      */
  358.     public function removeSubChapterDomain($subChapterDomains)
  359.     {
  360.         $this->subChapterDomains->removeElement($subChapterDomains);
  361.     }
  362.     /***
  363.      * Add workList
  364.      *
  365.      * @param \Bo\WorklistBundle\Entity\WorkList $workList
  366.      * @return Domain
  367.      
  368.     public function addWorkList(\Bo\WorklistBundle\Entity\WorkList $workList)
  369.     {
  370.         
  371.         $this->workList[] = $workList;
  372.         return $this;
  373.         
  374.     }
  375.     /***
  376.      * Remove workList
  377.      *
  378.      * @param \Bo\WorklistBundle\Entity\WorkList $workList
  379.      
  380.     public function removeWorkList(\Bo\WorklistBundle\Entity\WorkList $workList) 
  381.     {
  382.         $this->workList->removeElement($workList);
  383.     }
  384.     */
  385.     
  386.     /**
  387.      * Get workList
  388.      *
  389.      * @return \Doctrine\Common\Collections\Collection
  390.      */
  391.     public function getWorkList()
  392.     {
  393.         return $this->workList;
  394.     }
  395.     public function hasStatementLine($statementId)
  396.     {
  397.         if (!$this->statementLines->isEmpty()) {
  398.             foreach ($this->statementLines as $line) {
  399.                 if ($line->getId() == $statementId) {
  400.                     return true;
  401.                 }
  402.             }
  403.         }
  404.         return false;
  405.     }
  406.     public function firstVideoShow()
  407.     {
  408.         foreach ($this->subChapterDomains as $sd) {
  409.             if ($sd->isOnline()) {
  410.                 if (!$sd->getSubChapterDomainVideo()->isEmpty()) {
  411.                     foreach ($sd->getSubChapterDomainVideo() as $sdv) {
  412.                         if ($sdv->isOnline()) {
  413.                             return $sdv->getVideo();
  414.                         }
  415.                     }
  416.                 }
  417.             }
  418.         }
  419.         return null;
  420.     }
  421.     /**
  422.      * Add statementLines
  423.      *
  424.      * @param \Bo\ExerciseBundle\Entity\StatementLine $statementLines
  425.      * @return Domain
  426.      */
  427.     public function addStatementLines(StatementLine $statementLines)
  428.     {
  429.         $this->statementLines[] = $statementLines;
  430.         return $this;
  431.     }
  432.     /**
  433.      * Remove statementLines
  434.      *
  435.      * @param \Bo\ExerciseBundle\Entity\StatementLine $statementLines
  436.      */
  437.     public function removeStatementLine(StatementLine $statementLines)
  438.     {
  439.         $this->statementLines->removeElement($statementLines);
  440.     }
  441.     /**
  442.      * Get statementLines
  443.      *
  444.      * @return \Doctrine\Common\Collections\Collection
  445.      */
  446.     public function getStatementLines()
  447.     {
  448.         return $this->statementLines;
  449.     }
  450.     /**
  451.      * Add statementLines
  452.      *
  453.      * @param \Bo\ExerciseBundle\Entity\StatementLine $statementLines
  454.      * @return Domain
  455.      */
  456.     public function addStatementLine(StatementLine $statementLines)
  457.     {
  458.         $this->statementLines[] = $statementLines;
  459.         return $this;
  460.     }
  461.     /**
  462.      * Add workListNode
  463.      *
  464.      * @param \Bo\WorkListBundle\Entity\WorkListNode $workListNode
  465.      * @return Domain
  466.      */
  467.     public function addWorkListNode(WorkListNode $workListNode)
  468.     {
  469.         $this->workListNode[] = $workListNode;
  470.         return $this;
  471.     }
  472.     /**
  473.      * Remove workListNode
  474.      *
  475.      * @param \Bo\WorkListBundle\Entity\WorkListNode $workListNode
  476.      */
  477.     public function removeWorkListNode(WorkListNode $workListNode)
  478.     {
  479.         $this->workListNode->removeElement($workListNode);
  480.     }
  481.     /**
  482.      * Get workListNode
  483.      *
  484.      * @return \Doctrine\Common\Collections\Collection
  485.      */
  486.     public function getWorkListNode()
  487.     {
  488.         return $this->workListNode;
  489.     }
  490.     /**
  491.      * @param string $picture
  492.      */
  493.     public function setPicture($picture)
  494.     {
  495.         $this->picture = $picture;
  496.     }
  497.     /**
  498.      * @return string
  499.      */
  500.     public function getPicture()
  501.     {
  502.         return $this->picture;
  503.     }
  504.     /**
  505.      * @return int
  506.      */
  507.     public function getPictureMobileId()
  508.     {
  509.         return $this->pictureMobileId;
  510.     }
  511.     /**
  512.      * @param int $pictureMobileId
  513.      */
  514.     public function setPictureMobileId($pictureMobileId)
  515.     {
  516.         $this->pictureMobileId = $pictureMobileId;
  517.     }
  518.     /**
  519.      * @return string
  520.      */
  521.     public function getDescription()
  522.     {
  523.         return $this->description;
  524.     }
  525.     /**
  526.      * @param string $description
  527.      */
  528.     public function setDescription($description)
  529.     {
  530.         $this->description = $description;
  531.     }
  532.     /**
  533.      * @return string
  534.      */
  535.     public function getMetadescription()
  536.     {
  537.         return $this->metadescription;
  538.     }
  539.     /**
  540.      * @param string $metadescription
  541.      */
  542.     public function setMetadescription( $metadescription)
  543.     {
  544.         $this->metadescription = $metadescription;
  545.     }
  546.     /**
  547.      * @return mixed
  548.      */
  549.     public function getMissionExamProgram()
  550.     {
  551.         return $this->missionExamProgram;
  552.     }
  553.     /**
  554.      * @param mixed $missionExamProgram
  555.      */
  556.     public function setMissionExamProgram($missionExamProgram): void
  557.     {
  558.         $this->missionExamProgram = $missionExamProgram;
  559.     }
  560.     public function getFileIcon(): ?string
  561.     {
  562.         return $this->fileIcon;
  563.     }
  564.     public function setFileIcon(string $fileIcon): void
  565.     {
  566.         $this->fileIcon = $fileIcon;
  567.     }
  568. }