src/Entity/Users/Teacher.php line 24

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: audri
  5.  * Date: 26/02/15
  6.  * Time: 15:12
  7.  */
  8. namespace App\Entity\Users;
  9. use Bo\AdministratorsBundle\Entity\ValidateFlow;
  10. use App\Entity\Educational\Discipline;
  11. use App\Entity\Users\Child as Student;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Config\Definition\Exception\Exception;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use App\Entity\Users\User as Base;
  17. /**
  18.  * Class teacher
  19.  * @package Bo\UserBundle\Entity
  20.  * @ORM\Entity(repositoryClass="App\Repository\Users\TeacherRepository")
  21.  */
  22. class Teacher extends Base {
  23.     /**
  24.      * @var boolean $selected
  25.      * @ORM\Column(name="selected",type="boolean")
  26.      */
  27.     private $selected;
  28.     /**
  29.      * @var float
  30.      * @ORM\Column(name="contract_hours",type="float",nullable=true)
  31.      */
  32.     private $contractHours;
  33.     /**
  34.      * @var float
  35.      * @ORM\Column(name="hours_worked",type="float",nullable=true)
  36.      */
  37.     private $hoursWorked;
  38. /********************** ASSOCIATION ************************************/
  39.     /**
  40.      * @var Discipline $disciplines
  41.      * @ORM\ManyToMany(targetEntity="App\Entity\Educational\Discipline",inversedBy="teachers")
  42.      * @ORM\JoinTable(name="admin_teachers_disciplines")
  43.      */
  44.     private $disciplines;
  45.     /**
  46.      * @var Child $students
  47.      * @ORM\OneToMany(targetEntity="Child",mappedBy="teacher")
  48.      */
  49.     private $students;
  50.     /*
  51.      * @ORM\OneToMany(targetEntity="\Bo\AdministratorsBundle\Entity\ValidateFlow", mappedBy="teacher")
  52.      */
  53.     private $validateFlow;
  54.     /*
  55.      * @ORM\OneToMany(targetEntity="Bo\StudentBundle\Entity\Note", mappedBy="teacher")
  56.      */
  57.     private $notes;
  58.     /*
  59.      * @ORM\OneToMany(targetEntity="\Bo\TeacherBundle\Entity\AbstractTask", cascade={"persist"}, mappedBy="teacher" )
  60.      */
  61.     private $abstractTask;
  62.     public function __construct()
  63.     {
  64.         $this->disciplines   = new ArrayCollection();
  65.         $this->selected      = false;
  66.         $this->validateFlow  = new ArrayCollection();
  67.         $this->students      = new ArrayCollection();
  68.         parent::__construct();
  69.         $this->isVerified = true;
  70.     }
  71.     /**
  72.      * @return mixed
  73.      */
  74.     public function getDisciplines()
  75.     {
  76.         return $this->disciplines;
  77.     }
  78.     /**
  79.      * @param mixed $disciplines
  80.      */
  81.     public function addDisciplines($disciplines)
  82.     {
  83.         if(!in_array($disciplines,$this->disciplines))
  84.         {
  85.             $this->disciplines[] = $disciplines;
  86.         }
  87.     }
  88.     public function setDisciplines($disciplines)
  89.     {
  90.             $this->disciplines[] = $disciplines;
  91.     }
  92.     /**
  93.      * @return boolean
  94.      */
  95.     public function isSelected()
  96.     {
  97.         return $this->selected;
  98.     }
  99.     /**
  100.      * @param boolean $selected
  101.      */
  102.     public function setSelected($selected)
  103.     {
  104.         $this->selected = $selected;
  105.     }
  106.     public function getInfoTeacher()
  107.     {
  108.         $tab = array();
  109.         $tab["firstname"] = $this->firstname;
  110.         $tab["lastname"]  = $this->lastname;
  111.         $tab["username"]  = $this->username;
  112.         foreach($this->disciplines as $discipline)
  113.         {
  114.             $tab["disciplines"][] = $discipline->getTitle();
  115.         }
  116.         return $tab;
  117.     }
  118.     /**
  119.      * @return float
  120.      */
  121.     public function getContractHours()
  122.     {
  123.         return $this->contractHours;
  124.     }
  125.     /**
  126.      * @param float $contractHours
  127.      */
  128.     public function setContractHours($contractHours)
  129.     {
  130.         $this->contractHours = $contractHours;
  131.     }
  132.     /**
  133.      * @return float
  134.      */
  135.     public function getHoursWorked()
  136.     {
  137.         return $this->hoursWorked;
  138.     }
  139.     /**
  140.      * @param float $hoursWorked
  141.      */
  142.     public function setHoursWorked($hoursWorked)
  143.     {
  144.         $this->hoursWorked = $hoursWorked;
  145.     }
  146.     /**
  147.      * @return mixed
  148.      */
  149.     public function getStudents()
  150.     {
  151.         return $this->students;
  152.     }
  153.     /**
  154.      * @param mixed $students
  155.      */
  156.     public function setStudents($students)
  157.     {
  158.         $this->students = $students;
  159.     }
  160.     /**
  161.      * @param mixed $students
  162.      */
  163.     public function addStudents($students)
  164.     {
  165.         $this->students[] = $students;
  166.     }
  167.     /**
  168.      * Add notes
  169.      *
  170.      * @param \Bo\StudentBundle\Entity\Note $notes
  171.      * @return Teacher
  172.      */
  173.     public function addNote($notes)
  174.     {
  175.         $this->notes[] = $notes;
  176.         return $this;
  177.     }
  178.     /**
  179.      * Remove notes
  180.      *
  181.      * @param \Bo\StudentBundle\Entity\Note $notes
  182.      */
  183.     public function removeNote($notes)
  184.     {
  185.         $this->notes->removeElement($notes);
  186.     }
  187.     /**
  188.      * Get notes
  189.      *
  190.      * @return \Doctrine\Common\Collections\Collection
  191.      */
  192.     public function getNotes()
  193.     {
  194.         return $this->notes;
  195.     }
  196.     /**
  197.      * Add abstractTask
  198.      *
  199.      * @param \Bo\TeacherBundle\Entity\AbstractTask $abstractTask
  200.      * @return Teacher
  201.      */
  202.     public function addAbstractTask($abstractTask)
  203.     {
  204.         $this->abstractTask[] = $abstractTask;
  205.         return $this;
  206.     }
  207.     /**
  208.      * Remove abstractTask
  209.      *
  210.      * @param \Bo\TeacherBundle\Entity\AbstractTask $abstractTask
  211.      */
  212.     public function removeAbstractTask($abstractTask)
  213.     {
  214.         $this->abstractTask->removeElement($abstractTask);
  215.     }
  216.     /**
  217.      * Get abstractTask
  218.      *
  219.      * @return \Doctrine\Common\Collections\Collection
  220.      */
  221.     public function getAbstractTask()
  222.     {
  223.         return $this->abstractTask;
  224.     }
  225.     /**
  226.      * {@inheritdoc}
  227.      */
  228.     public function __toString()
  229.     {
  230.         return $this->getFullname();
  231.     }
  232.     /**
  233.      * Get selected
  234.      *
  235.      * @return boolean 
  236.      */
  237.     public function getSelected()
  238.     {
  239.         return $this->selected;
  240.     }
  241.     /**
  242.      * Add disciplines
  243.      *
  244.      * @param \Bo\ReferencesBundle\Entity\Discipline $disciplines
  245.      * @return Teacher
  246.      */
  247.     public function addDiscipline(Discipline $disciplines)
  248.     {
  249.         $this->disciplines[] = $disciplines;
  250.         return $this;
  251.     }
  252.     /**
  253.      * Remove disciplines
  254.      *
  255.      * @param \Bo\ReferencesBundle\Entity\Discipline $disciplines
  256.      */
  257.     public function removeDiscipline(Discipline $disciplines)
  258.     {
  259.         $this->disciplines->removeElement($disciplines);
  260.     }
  261.     /**
  262.      * Add students
  263.      *
  264.      * @param \Bo\StudentBundle\Entity\Student $students
  265.      * @return Teacher
  266.      */
  267.     public function addStudent(Child $students)
  268.     {
  269.         $this->students[] = $students;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Remove students
  274.      *
  275.      * @param Child $students
  276.      */
  277.     public function removeStudent(Child $students)
  278.     {
  279.         $this->students->removeElement($students);
  280.     }
  281.     /**
  282.      * Add validateFlow
  283.      *
  284.      * @param \Bo\AdministratorsBundle\Entity\ValidateFlow $validateFlow
  285.      * @return Teacher
  286.      */
  287.     public function addValidateFlow($validateFlow)
  288.     {
  289.         $this->validateFlow[] = $validateFlow;
  290.         return $this;
  291.     }
  292.     /**
  293.      * Remove validateFlow
  294.      *
  295.      * @param \Bo\AdministratorsBundle\Entity\ValidateFlow $validateFlow
  296.      */
  297.     public function removeValidateFlow($validateFlow)
  298.     {
  299.         $this->validateFlow->removeElement($validateFlow);
  300.     }
  301.     /**
  302.      * Get validateFlow
  303.      *
  304.      * @return \Doctrine\Common\Collections\Collection 
  305.      */
  306.     public function getValidateFlow()
  307.     {
  308.         return $this->validateFlow;
  309.     }
  310. }