| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- <?php
- namespace AppBundle\Entity\Booking;
- use AppBundle\Entity\Education\EducationCurriculum;
- use AppBundle\Entity\Organization\Jury;
- use AppBundle\Enum\Education\PratiqueEnum;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use Doctrine\Common\Collections\ArrayCollection;
- use AppBundle\Validator\Constraints\Booking as OpentalentEventAssert;
- /**
- * Examen
- *
- * @Iri("http://schema.org/Examen")
- * @OpentalentEventAssert\Examen()
- */
- #[ORM\Entity]
- class Examen extends AbstractBooking
- {
- /**
- * @var ArrayCollection<ExamenRecur>
- */
- #[Assert\Valid]
- #[ORM\OneToMany(targetEntity: 'ExamenRecur', mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
- #[Groups(['examen_bookingrecur', 'planning_detail', 'examen_informations_edit'])]
- protected $eventRecur;
- /**
- * @var ArrayCollection<Examen>
- */
- #[ORM\OneToMany(targetEntity: 'Examen', mappedBy: 'parent', orphanRemoval: true)]
- #[Groups(['examen_timeline'])]
- private $timeline;
- /**
- * @var \AppBundle\Entity\Booking\Examen
- */
- #[ORM\ManyToOne(targetEntity: 'Examen', inversedBy: 'timeline')]
- #[Groups(['examen'])]
- private $parent;
- /**
- * @var string
- */
- #[Assert\Type(type: 'string')]
- #[Assert\Choice(callback: ['\AppBundle\Enum\Booking\ExamenTimelineTypeEnum', 'toArray'], multiple: false, min: 1)]
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Groups(['examen'])]
- private $type;
- /**
- * @var Jury
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Jury', inversedBy: 'examens', cascade: ['persist'])]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['examen', 'examenconvocation_list_examen', 'examen_details', 'planning_detail', 'presence_attendance', 'examen_informations_edit'])]
- private $jury;
- /**
- * @var string
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Education\Education', inversedBy: 'examens')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['examen', 'examenconvocation_list_examen', 'planning_list', 'presence_attendance', 'examen_details', 'planning_detail', 'report_card_examenconvocations', 'examen_informations_edit'])]
- private $education;
- /**
- * @var EducationCurriculum
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Education\EducationCurriculum')]
- #[Groups(['examen_educationcurriculum', 'planning_detail', 'examenconvocation_list_examen', 'planning_list', 'presence_attendance', 'examen_details', 'examen_informations_edit'])]
- private $educationCurriculum;
- /**
- * @var ArrayCollection<ExamenConvocation>
- */
- #[Assert\Valid]
- #[ORM\OneToMany(targetEntity: 'ExamenConvocation', mappedBy: 'examen', cascade: ['persist'], orphanRemoval: true)]
- #[Groups(['examen_examenconvocation', 'presence_attendance', 'examen_details', 'planning_detail', 'examen_informations_edit'])]
- private $convocation;
- /**
- * var ArrayCollection<AttendanceBooking>
- */
- #[Assert\Valid]
- #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\AttendanceBooking', cascade: ['persist'], mappedBy: 'examen', orphanRemoval: true)]
- #[ORM\JoinColumn(nullable: false)]
- #[Groups(['examen_attendancebooking', 'presence_attendance', 'planning_detail', 'examen_details'])]
- private $attendanceBooking;
- /**
- * @var string
- */
- private $fullLabelTemplate;
- public function __construct()
- {
- parent::__construct();
- $this->educationCurriculum = new ArrayCollection();
- $this->convocation = new ArrayCollection();
- $this->attendanceBooking = new ArrayCollection();
- }
- /**
- * Sets jury.
- *
- * @param Jury $jury
- *
- * @return $this
- */
- public function setJury(\AppBundle\Entity\Organization\Jury $jury = null)
- {
- $this->jury = $jury;
- return $this;
- }
- /**
- * Gets jury.
- *
- * @return Jury
- */
- public function getJury()
- {
- return $this->jury;
- }
- /**
- * Add educationCurriculum
- *
- * @param EducationCurriculum $educationCurriculum
- * @return EducationCurriculum
- */
- public function addEducationCurriculum(\AppBundle\Entity\Education\EducationCurriculum $educationCurriculum)
- {
- $this->educationCurriculum[] = $educationCurriculum;
- return $this;
- }
- /**
- * Remove educationCurriculum
- *
- * @param EducationCurriculum $educationCurriculum
- */
- public function removeEducationCurriculum(\AppBundle\Entity\Education\EducationCurriculum $educationCurriculum)
- {
- $this->educationCurriculum->removeElement($educationCurriculum);
- }
- /**
- * Get educationCurriculum
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getEducationCurriculum()
- {
- return $this->educationCurriculum;
- }
- /**
- * Add convocation
- *
- * @param ExamenConvocation $convocation
- * @return $this
- */
- public function addConvocation(ExamenConvocation $convocation)
- {
- $convocation->setExamen($this);
- $this->convocation[] = $convocation;
- return $this;
- }
- /**
- * Remove convocation
- *
- * @param ExamenConvocation $convocation
- * @return $this
- */
- public function removeConvocation(ExamenConvocation $convocation)
- {
- $this->convocation->removeElement($convocation);
- return $this;
- }
- /**
- * Get convocation
- *
- * @return ArrayCollection<ExamenConvocation>
- */
- public function getConvocation()
- {
- return $this->convocation;
- }
- /**
- * {@inheritdoc}
- */
- public function getParticipants() {
- $participants = new ArrayCollection();
- array_map(function (ExamenConvocation $c) use ($participants) { $participants->add($c->getStudent()->getPerson());}, $this->getConvocation()->toArray());
- return $participants;
- }
- /**
- * Set type
- *
- * @param string $type
- *
- * @return Examen
- */
- public function setType($type)
- {
- $this->type = $type;
- return $this;
- }
- /**
- * Get type
- *
- * @return string
- */
- public function getType()
- {
- return $this->type;
- }
- /**
- * Add timeline
- *
- * @param \AppBundle\Entity\Booking\Examen $timeline
- *
- * @return Examen
- */
- public function addTimeline(\AppBundle\Entity\Booking\Examen $timeline)
- {
- $this->timeline[] = $timeline;
- return $this;
- }
- /**
- * Remove timeline
- *
- * @param \AppBundle\Entity\Booking\Examen $timeline
- */
- public function removeTimeline(\AppBundle\Entity\Booking\Examen $timeline)
- {
- $this->timeline->removeElement($timeline);
- }
- /**
- * Get timeline
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getTimeline()
- {
- return $this->timeline;
- }
- /**
- * Set parent
- *
- * @param \AppBundle\Entity\Booking\Examen $parent
- *
- * @return Examen
- */
- public function setParent(\AppBundle\Entity\Booking\Examen $parent = null)
- {
- $this->parent = $parent;
- return $this;
- }
- /**
- * Get parent
- *
- * @return \AppBundle\Entity\Booking\Examen
- */
- public function getParent()
- {
- return $this->parent;
- }
- /**
- * Set education
- *
- * @param \AppBundle\Entity\Education\Education $education
- *
- * @return Examen
- */
- public function setEducation(\AppBundle\Entity\Education\Education $education = null)
- {
- $this->education = $education;
- return $this;
- }
- /**
- * Get education
- *
- * @return \AppBundle\Entity\Education\Education
- */
- public function getEducation()
- {
- return $this->education;
- }
- /**
- * Add attendanceBooking
- *
- * @param \AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking
- *
- * @return AbstractBooking
- */
- public function addAttendanceBooking(\AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking)
- {
- $attendanceBooking->setExamen($this);
- $this->attendanceBooking[] = $attendanceBooking;
- return $this;
- }
- /**
- * Remove attendanceBooking
- *
- * @param \AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking
- */
- public function removeAttendanceBooking(\AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking)
- {
- $this->attendanceBooking->removeElement($attendanceBooking);
- }
- /**
- * Get attendanceBooking
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getAttendanceBooking()
- {
- return $this->attendanceBooking;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelTemplate()
- {
- $dateTimeStart = $this->getDatetimeStart();
- $timezone = 'Europe/Paris';
- $dateTimeStart->setTimezone(new \DateTimeZone($timezone));
- $dateTimeStartFormatted = [];
- $dateTimeStartFormatted[] = ['value' => $dateTimeStart->format('l') , 'translate' => true];
- $dateTimeStartFormatted[] = $dateTimeStart->format('à H:i');
- if(is_null($this->getEducation())){
- return [];
- }
- $educationCurricullums = [];
- foreach ($this->getEducationCurriculum() as $edc){
- $educationCurricullums[] = ( $edc->getCycle() ? $edc->getCycle()->getLabel() : '' );
- $educationCurricullums[] = ['value' => $edc->getYear(), 'translate' => true];
- $educationCurricullums[] = $edc->getLevel();
- $educationCurricullums[] = ', ';
- }
- $fullLabelTemplate = [
- $this->getName(),
- $this->getEducation()->getEducationCategory()->getLabel(),
- ($this->getEducation()->getEducationComplement() && $this->getEducation()->getEducationComplement()->getName() !== PratiqueEnum::NONE)?$this->getEducation()->getEducationComplement()->getName():''
- ];
- return array_merge($fullLabelTemplate, $educationCurricullums, $dateTimeStartFormatted);
- }
- }
|