src/Entity/SchoolClass.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\SchoolClassTeacherMapping;
  7. class SchoolClass {
  8.     /**
  9.      * @var integer
  10.      */
  11.     private $id;
  12.     /**
  13.      * @var string|null
  14.      */
  15.     private $classCode;
  16.     /**
  17.      * @var string|null
  18.      */
  19.     private $numberPart;
  20.     /**
  21.      * @var string|null
  22.      */
  23.     private $textPart;
  24.     /**
  25.      * @var string
  26.      */
  27.     private $userPassword;
  28.     /**
  29.      * @var \App\Entity\User
  30.      */
  31.     private $schoolClassUser;
  32.     /**
  33.      * @var \DateTime
  34.      */
  35.     private $createdAt;
  36.     /**
  37.      * @var \Doctrine\Common\Collections\Collection
  38.      */
  39.     private $schoolClassTeacherMappings;
  40.     /**
  41.      * @var \App\Entity\School
  42.      */
  43.     private $school;
  44.     /**
  45.      * @var \App\Entity\SchoolClassGrade
  46.      */
  47.     private $grade;
  48.     /**
  49.      * @var \App\Entity\SchoolClassYear
  50.      */
  51.     private $schoolClassYear;
  52.     /**
  53.      * @var int
  54.      */
  55.     private $numberOfStudents;
  56.     /**
  57.      * @var int
  58.      */
  59.     private $historyId;
  60.     /**
  61.      * @var \App\Entity\SchoolClassState
  62.      */
  63.     private $schoolClassState;
  64.     /**
  65.      * @var \Doctrine\Common\Collections\Collection
  66.      */
  67.     private $gameCategories;
  68.     /**
  69.      * @var \DateTime|null
  70.      */
  71.     private $deletedAt;
  72.     /**
  73.      * Constructor
  74.      */
  75.     public function __construct() {
  76.         $this->gameCategories = new ArrayCollection();
  77.         $this->schoolClassTeacherMappings = new ArrayCollection();
  78.     }
  79.     /**
  80.      * Get id
  81.      *
  82.      * @return integer
  83.      */
  84.     public function getId() {
  85.         return $this->id;
  86.     }
  87.     /**
  88.      * Set createdAt
  89.      *
  90.      * @param \DateTime $createdAt
  91.      *
  92.      * @return SchoolClass
  93.      */
  94.     public function setCreatedAt($createdAt) {
  95.         $this->createdAt $createdAt;
  96.         return $this;
  97.     }
  98.     /**
  99.      * Get createdAt
  100.      *
  101.      * @return \DateTime
  102.      */
  103.     public function getCreatedAt() {
  104.         return $this->createdAt;
  105.     }
  106.     /**
  107.      * Add schoolClassTeacherMapping
  108.      *
  109.      * @param \App\Entity\SchoolClassTeacherMapping $schoolClassTeacherMapping
  110.      *
  111.      * @return SchoolClass
  112.      */
  113.     public function addSchoolClassTeacherMapping(\App\Entity\SchoolClassTeacherMapping $schoolClassTeacherMapping) {
  114.         $this->schoolClassTeacherMappings[] = $schoolClassTeacherMapping;
  115.         return $this;
  116.     }
  117.     /**
  118.      * Remove schoolClassTeacherMapping
  119.      *
  120.      * @param \App\Entity\SchoolClassTeacherMapping $schoolClassTeacherMapping
  121.      */
  122.     public function removeSchoolClassTeacherMapping(\App\Entity\SchoolClassTeacherMapping $schoolClassTeacherMapping) {
  123.         $this->schoolClassTeacherMappings->removeElement($schoolClassTeacherMapping);
  124.     }
  125.     /**
  126.      * Get schoolClassTeacherMappings
  127.      *
  128.      * @return \Doctrine\Common\Collections\Collection
  129.      */
  130.     public function getSchoolClassTeacherMappings() {
  131.         return $this->schoolClassTeacherMappings;
  132.     }
  133.     /**
  134.      * Set school
  135.      *
  136.      * @param \App\Entity\School $school
  137.      *
  138.      * @return SchoolClass
  139.      */
  140.     public function setSchool(\App\Entity\School $school null) {
  141.         $this->school $school;
  142.         return $this;
  143.     }
  144.     /**
  145.      * Get school
  146.      *
  147.      * @return \App\Entity\School
  148.      */
  149.     public function getSchool() {
  150.         return $this->school;
  151.     }
  152.     /**
  153.      * Set grade
  154.      *
  155.      * @param \App\Entity\SchoolClassGrade $grade
  156.      *
  157.      * @return SchoolClass
  158.      */
  159.     public function setGrade(\App\Entity\SchoolClassGrade $grade null) {
  160.         $this->grade $grade;
  161.         return $this;
  162.     }
  163.     /**
  164.      * Get grade
  165.      *
  166.      * @return \App\Entity\SchoolClassGrade
  167.      */
  168.     public function getGrade() {
  169.         return $this->grade;
  170.     }
  171.     /**
  172.      * Set schoolClassYear
  173.      *
  174.      * @param \App\Entity\SchoolClassYear $schoolClassYear
  175.      *
  176.      * @return SchoolClass
  177.      */
  178.     public function setSchoolClassYear(\App\Entity\SchoolClassYear $schoolClassYear null) {
  179.         $this->schoolClassYear $schoolClassYear;
  180.         return $this;
  181.     }
  182.     /**
  183.      * Get schoolClassYear
  184.      *
  185.      * @return \App\Entity\SchoolClassYear
  186.      */
  187.     public function getSchoolClassYear() {
  188.         return $this->schoolClassYear;
  189.     }
  190.     /**
  191.      * Set historyId.
  192.      *
  193.      * @param int $historyId
  194.      *
  195.      * @return SchoolClass
  196.      */
  197.     public function setHistoryId($historyId) {
  198.         $this->historyId $historyId;
  199.         return $this;
  200.     }
  201.     /**
  202.      * Get historyId.
  203.      *
  204.      * @return int
  205.      */
  206.     public function getHistoryId() {
  207.         return $this->historyId;
  208.     }
  209.     /**
  210.      * Set deletedAt.
  211.      *
  212.      * @param \DateTime|null $deletedAt
  213.      *
  214.      * @return SchoolClass
  215.      */
  216.     public function setDeletedAt($deletedAt null) {
  217.         $this->deletedAt $deletedAt;
  218.         return $this;
  219.     }
  220.     /**
  221.      * Get deletedAt.
  222.      *
  223.      * @return \DateTime|null
  224.      */
  225.     public function getDeletedAt() {
  226.         return $this->deletedAt;
  227.     }
  228.     /**
  229.      * Set numberOfStudents.
  230.      *
  231.      * @param int $numberOfStudents
  232.      *
  233.      * @return SchoolClass
  234.      */
  235.     public function setNumberOfStudents($numberOfStudents) {
  236.         $this->numberOfStudents $numberOfStudents;
  237.         return $this;
  238.     }
  239.     /**
  240.      * Get numberOfStudents.
  241.      *
  242.      * @return int
  243.      */
  244.     public function getNumberOfStudents() {
  245.         return $this->numberOfStudents;
  246.     }
  247.     /**
  248.      * Set userPassword.
  249.      *
  250.      * @param string $userPassword
  251.      *
  252.      * @return SchoolClass
  253.      */
  254.     public function setUserPassword($userPassword) {
  255.         $this->userPassword $userPassword;
  256.         return $this;
  257.     }
  258.     /**
  259.      * Get userPassword.
  260.      *
  261.      * @return string
  262.      */
  263.     public function getUserPassword() {
  264.         return $this->userPassword;
  265.     }
  266.     /**
  267.      * Set schoolClassUser.
  268.      *
  269.      * @param \App\Entity\User|null $schoolClassUser
  270.      *
  271.      * @return SchoolClass
  272.      */
  273.     public function setSchoolClassUser(\App\Entity\User $schoolClassUser null) {
  274.         $this->schoolClassUser $schoolClassUser;
  275.         return $this;
  276.     }
  277.     /**
  278.      * Get schoolClassUser.
  279.      *
  280.      * @return \App\Entity\User|null
  281.      */
  282.     public function getSchoolClassUser() {
  283.         return $this->schoolClassUser;
  284.     }
  285.     /**
  286.      * Get teacherNames
  287.      *
  288.      * @return string
  289.      */
  290.     public function getTeacherNames() {
  291.         $names '';
  292.         /* @var $teacherMapping SchoolClassTeacherMapping */
  293.         foreach ($this->schoolClassTeacherMappings as $teacherMapping) {
  294.             $names $names $teacherMapping->getUser()->getUserData()->getFullName() . ' ';
  295.         }
  296.         return $names;
  297.     }
  298.     /**
  299.      * Set numberPart.
  300.      *
  301.      * @param string|null $numberPart
  302.      *
  303.      * @return SchoolClass
  304.      */
  305.     public function setNumberPart($numberPart null) {
  306.         $this->numberPart $numberPart;
  307.         return $this;
  308.     }
  309.     /**
  310.      * Get numberPart.
  311.      *
  312.      * @return string|null
  313.      */
  314.     public function getNumberPart() {
  315.         return $this->numberPart;
  316.     }
  317.     /**
  318.      * Set textPart.
  319.      *
  320.      * @param string|null $textPart
  321.      *
  322.      * @return SchoolClass
  323.      */
  324.     public function setTextPart($textPart null) {
  325.         $this->textPart $textPart;
  326.         return $this;
  327.     }
  328.     /**
  329.      * Get textPart.
  330.      *
  331.      * @return string|null
  332.      */
  333.     public function getTextPart() {
  334.         return $this->textPart;
  335.     }
  336.     /**
  337.      * Get name
  338.      *
  339.      * @return string
  340.      */
  341.     public function getName() {
  342.         return trim($this->numberPart .''$this->textPart);
  343.     }
  344.     public function getClassCode(): ?string {
  345.         return $this->classCode;
  346.     }
  347.     public function setClassCode(?string $classCode): void {
  348.         $this->classCode $classCode;
  349.     }
  350.     public function getFullName() {
  351.         $name $this->getName();
  352.         $schoolYear '';
  353.         if (!empty($this->schoolClassYear)) {
  354.             $schoolYear ' (' $this->schoolClassYear->getName() . ')';
  355.         }
  356.         return trim("$name $schoolYear");
  357.     }
  358.     public function getNameExtended() {
  359.         $count $this->numberOfStudents;
  360.         $numberPart $this->numberPart;
  361.         $textPart $this->textPart;
  362.         return trim("$numberPart $textPart ($count SchülerInnen)");
  363.     }
  364.     /**
  365.      * Set schoolClassState.
  366.      *
  367.      * @param \App\Entity\SchoolClassState|null $schoolClassState
  368.      *
  369.      * @return SchoolClass
  370.      */
  371.     public function setSchoolClassState(\App\Entity\SchoolClassState $schoolClassState null) {
  372.         $this->schoolClassState $schoolClassState;
  373.         return $this;
  374.     }
  375.     /**
  376.      * Get schoolClassState.
  377.      *
  378.      * @return \App\Entity\SchoolClassState|null
  379.      */
  380.     public function getSchoolClassState() {
  381.         return $this->schoolClassState;
  382.     }
  383.     public function getGameCategories() {
  384.         return $this->gameCategories;
  385.     }
  386.     public function setGameCategories($gameCategories) {
  387.         $this->gameCategories $gameCategories;
  388.     }
  389.     public function addGameCategory($gameCategory) {
  390.         $this->gameCategories->add($gameCategory);
  391.     }
  392.     public function isActive() {
  393.         if (empty($this->schoolClassState)) {
  394.             return false;
  395.         }
  396.         $stateID $this->schoolClassState->getId();
  397.         if ($stateID != 1) {
  398.             return false;
  399.         }
  400.         return true;
  401.     }
  402. }