src/Entity/Participant.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\LineParticipant;
  4. use App\Repository\ParticipantRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassParticipantRepository::class)]
  10. class Participant
  11. {
  12.     const TYPE_AUTEUR 1;
  13.     const TYPE_PRESENTATEUR 2;
  14.     const TYPE_MODERATOR 3;
  15.     const TYPE_CONFERENCIER 4;
  16.     const STATUS_DRAFT 1;
  17.     const STATUS_VALID 2;
  18.     const STATUS_FAILED 3;
  19.     const STATUS_WAITING 4;
  20.     const STATUS_REFUSED 5// ce status est ajouté pour le caas de refus d'administrateur
  21.     const STATUS_PAYMENT_PENDING "Pending";
  22.     const STATUS_PAYMENT_SUCCESS "Success";
  23.     const STATUS_PAYMENT_FAILED "Failed";
  24.     const SEXE_HOMME 1;
  25.     const SEXE_FEMME 2;
  26.     // const CV_MARRIED = 1;
  27.     // const CV_SINGLE = 2;
  28.     const CV_MR 1;
  29.     const CV_MME 2;
  30.     const CV_MLLE 3;
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     private ?int $id null;
  35.     #[ORM\Column(length255)]
  36.     private ?string $firstname null;
  37.     #[ORM\Column(length255)]
  38.     private ?string $lastname null;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?string $mail null;
  41.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  42.     private ?int $civility null;
  43.     #[ORM\Column(type'datetime')]
  44.     private $createdAt;
  45.     #[ORM\Column(type'datetime'nullabletrue)]
  46.     private $updatedAt;
  47.     #[ORM\OneToOne(targetEntityUser::class, inversedBy'participant')]
  48.     #[ORM\JoinColumn(nullabletrue)]
  49.     private ?User $user null;
  50.     #[ORM\Column(nullabletrueoptions: ['default' => false])]
  51.     private ?bool $moderator false;
  52.     #[ORM\Column(typeTypes::SMALLINT)]
  53.     private ?int $status null;
  54.     /**
  55.      * @deprecated
  56.      */
  57.     #[ORM\Column(typeTypes::SMALLINT)]
  58.     private ?int $type null;
  59.     /** @var LineParticipant[]|ArrayCollection|Collection<int,LineParticipant> */
  60.     #[ORM\ManyToMany(targetEntityLineParticipant::class, mappedBy'participants'cascade: ["persist"])] // , "remove"
  61.     # [ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
  62.     private Collection $lineParticipants;
  63.     /** @var Line[]|ArrayCollection|Collection<int,Line> */
  64.     #[ORM\ManyToMany(targetEntityLine::class, mappedBy'listOfpresentateurs')]
  65.     private Collection $listOfpresentateursLines;
  66.     /** @var Line[]|ArrayCollection|Collection<int,Line> */
  67.     #[ORM\ManyToMany(targetEntityLine::class, mappedBy'listOfauteurs')]
  68.     private Collection $listOfauteursLines;
  69.     /** @var Line[]|ArrayCollection|Collection<int,Line> */
  70.     #[ORM\ManyToMany(targetEntityLine::class, mappedBy'listOfmoderators')]
  71.     private Collection $listOfmoderatorsLines;
  72.     private $listOfAuteurLineId = [];
  73.     private $listOfPresentateurLineId = [];
  74.     #[ORM\Column(nullabletrue)]
  75.     private ?array $email_history null;
  76.     #[ORM\ManyToOne(inversedBy'participants')]
  77.     private ?Evenement $event null;
  78.     #[ORM\Column(nullabletrue)]
  79.     private ?bool $is_author null;
  80.     #[ORM\Column(nullabletrue)]
  81.     private ?bool $is_presenter null;
  82.     #[ORM\Column(nullabletrue)]
  83.     private ?bool $is_conferencier null;
  84.     #[ORM\Column(nullabletrue)]
  85.     private ?bool $is_responsable null;
  86.     #[ORM\Column(nullabletrue)]
  87.     private ?bool $is_communaute_scientifique null;
  88.     #[ORM\Column(nullabletrue)]
  89.     private ?bool $is_commite_organisation null;
  90.     public function __construct()
  91.     {
  92.         $this->listOfpresentateursLines = new ArrayCollection();
  93.         $this->listOfauteursLines = new ArrayCollection();
  94.         $this->lineParticipants = new ArrayCollection();
  95.         $this->listOfmoderatorsLines = new ArrayCollection();
  96.         $this->moderator false;
  97.     }
  98.     public function __toString(): string
  99.     {
  100.         return $this->getFullname();
  101.     }
  102.     public function getFullname(): string
  103.     {
  104.         return trim($this->firstname ' ' $this->lastname);
  105.     }
  106.     public function getId(): ?int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function getFirstname(): ?string
  111.     {
  112.         return $this->firstname;
  113.     }
  114.     public function setFirstname(string $firstname): self
  115.     {
  116.         $this->firstname $firstname;
  117.         return $this;
  118.     }
  119.     public function getLastname(): ?string
  120.     {
  121.         return $this->lastname;
  122.     }
  123.     public function setLastname(string $lastname): self
  124.     {
  125.         $this->lastname $lastname;
  126.         return $this;
  127.     }
  128.     public function getMail(): ?string
  129.     {
  130.         if ($this->mail) {
  131.             return $this->mail;
  132.         }
  133.         return $this->user?->getEmail();
  134.     }
  135.     /**
  136.      * Set the value of mail
  137.      */
  138.     public function setmail(?string $mailbool $updateUser false): self
  139.     {
  140.         $this->mail $mail;
  141.         if ($this->user && $updateUser) {
  142.             $this->user->setEmail($mail);
  143.         }
  144.         return $this;
  145.     }
  146.     public function getTitle(): ?string
  147.     {
  148.         return $this->user?->getTitle();
  149.     }
  150.     public function getCivility(): ?int
  151.     {
  152.         if ($this->user) {
  153.             if (is_null($this->user->getCivility())) {
  154.                 if ($this->user->getSexe() == self::SEXE_HOMME) {
  155.                     $this->user->setCivility(self::CV_MR);
  156.                 } elseif ($this->user->getSexe() == self::SEXE_FEMME) {
  157.                     $this->user->setCivility(self::CV_MME);
  158.                 }
  159.             }
  160.             return $this->user->getCivility();
  161.         }
  162.         return $this->civility;
  163.     }
  164.     public function setCivility(int $civility): self
  165.     {
  166.         $this->civility $civility;
  167.         if($this->user) {
  168.             $this->user->setCivility($civility);
  169.         }
  170.         return $this;
  171.     }
  172.     public function getSexe(): ?int
  173.     {
  174.         return $this->user?->getSexe();
  175.     }
  176.     public function getCountry(): ?string
  177.     {
  178.         return $this->user?->getCountry();
  179.     }
  180.     public function getAdresse(): ?string
  181.     {
  182.         return $this->user?->getAdresse();
  183.     }
  184.     public function getCity(): ?string
  185.     {
  186.         return $this->user?->getCity();
  187.     }
  188.     public function getPostalCode(): ?int
  189.     {
  190.         return $this->user?->getPostalCode();
  191.     }
  192.     public function getWorkplace(): ?string
  193.     {
  194.         return $this->user?->getWorkplace();
  195.     }
  196.     public function getMobile(): ?string
  197.     {
  198.         return $this->user?->getMobile();
  199.     }
  200.     public function getPhone(): ?string
  201.     {
  202.         return $this->user?->getPhone();
  203.     }
  204.     public function getSpeciality(): ?string
  205.     {
  206.         return $this->user?->getSpeciality();
  207.     }
  208.     public function getActivity(): ?string
  209.     {
  210.         return $this->user?->getActivity();
  211.     }
  212.     public function getCreatedAt(): ?\DateTimeInterface
  213.     {
  214.         return $this->createdAt;
  215.     }
  216.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  217.     {
  218.         $this->createdAt $createdAt;
  219.         return $this;
  220.     }
  221.     public function getUpdatedAt(): ?\DateTimeInterface
  222.     {
  223.         return $this->updatedAt;
  224.     }
  225.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  226.     {
  227.         $this->updatedAt $updatedAt;
  228.         return $this;
  229.     }
  230.     public function isStatus(): ?bool
  231.     {
  232.         return $this->status;
  233.     }
  234.     public function getStatus(): ?int
  235.     {
  236.         return $this->status;
  237.     }
  238.     public function setStatus(int $status): self
  239.     {
  240.         $this->status $status;
  241.         return $this;
  242.     }
  243.     /**
  244.      * @deprecated
  245.      *
  246.      * @return integer|null
  247.      */
  248.     public function getType(): ?int
  249.     {
  250.         return $this->type;
  251.     }
  252.     /**
  253.      * @deprecated
  254.      *
  255.      * @param integer $type
  256.      * @return self
  257.      */
  258.     public function setType(int $type): self
  259.     {
  260.         $this->type $type;
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return Collection<int, Line>
  265.      */
  266.     public function getListOfpresentateursLines(): Collection
  267.     {
  268.         return $this->listOfpresentateursLines;
  269.     }
  270.     public function addListOfpresentateursLine(Line $listOfpresentateursLine): self
  271.     {
  272.         if (!$this->listOfpresentateursLines->contains($listOfpresentateursLine)) {
  273.             $this->listOfpresentateursLines->add($listOfpresentateursLine);
  274.             $listOfpresentateursLine->addListOfpresentateur($this);
  275.         }
  276.         return $this;
  277.     }
  278.     public function removeListOfpresentateursLine(Line $listOfpresentateursLine): self
  279.     {
  280.         if ($this->listOfpresentateursLines->removeElement($listOfpresentateursLine)) {
  281.             $listOfpresentateursLine->removeListOfpresentateur($this);
  282.         }
  283.         return $this;
  284.     }
  285.     /**
  286.      * @return Collection<int,Line>|Line[]
  287.      */
  288.     public function getListOfauteursLines(): Collection
  289.     {
  290.         return $this->listOfauteursLines;
  291.     }
  292.     /**
  293.      * returns an array of the ids of lines where participant is an author
  294.      * @param int $eventId (optional) specify from which event to collect lines
  295.      * @return array
  296.      */
  297.     public function getListofAuteurLinesId($eventId null): array
  298.     {
  299.         $data = [];
  300.         /** @var Line $line */
  301.         foreach ($this->listOfauteursLines as $line) {
  302.             if ($eventId != null) {
  303.                 //collect only lines corresponding to $eventId
  304.                 if ($eventId == $line->getEvenement()->getId()) {
  305.                     $data[] = $line->getId();
  306.                 }
  307.             } else {
  308.                 //collect lines for all  events
  309.                 $data[] = $line->getId();
  310.             }
  311.         }
  312.         $this->listOfAuteurLineId $data;
  313.         return $data;
  314.     }
  315.     public function addListOfauteursLine(Line $listOfauteursLine): self
  316.     {
  317.         if (!$this->listOfauteursLines->contains($listOfauteursLine)) {
  318.             $this->listOfauteursLines->add($listOfauteursLine);
  319.             $listOfauteursLine->addListOfauteur($this);
  320.         }
  321.         return $this;
  322.     }
  323.     public function removeListOfauteursLine(Line $listOfauteursLine): self
  324.     {
  325.         if ($this->listOfauteursLines->removeElement($listOfauteursLine)) {
  326.             $listOfauteursLine->removeListOfauteur($this);
  327.         }
  328.         return $this;
  329.     }
  330.     /**
  331.      * Get the value of lineParticipants
  332.      */
  333.     public function getLineParticipants(): ?Collection
  334.     {
  335.         return $this->lineParticipants;
  336.     }
  337.     /**
  338.      * Set the value of lineParticipants
  339.      *
  340.      * @return  self
  341.      */
  342.     public function setLineParticipants(?Collection $lineParticipants): self
  343.     {
  344.         $this->lineParticipants $lineParticipants;
  345.         return $this;
  346.     }
  347.     public function addLineParticipant(LineParticipant $lineParticipant): void
  348.     {
  349.         if (!$this->lineParticipants->contains($lineParticipant)) {
  350.             $this->lineParticipants->add($lineParticipant);
  351.         }
  352.     }
  353.     public function removeLineParticipant(LineParticipant $lineParticipant): void
  354.     {
  355.         if (!$this->lineParticipants->contains($lineParticipant)) {
  356.             $this->lineParticipants->removeElement($lineParticipant);
  357.         }
  358.     }
  359.     public function getEmailHistory(): ?array
  360.     {
  361.         return $this->email_history;
  362.     }
  363.     public function setEmailHistory(?array $email_history): static
  364.     {
  365.         $this->email_history $email_history;
  366.         return $this;
  367.     }
  368.     public function getEmailHistoryWTheme(string $theme)
  369.     {
  370.         $j 0;
  371.         $emailHistory $this->getEmailHistory();
  372.         if ($emailHistory) {
  373.             foreach ($emailHistory as $email) {
  374.                 if ($email['theme'] == $theme) {
  375.                     break;
  376.                 }
  377.                 $j++;
  378.             }
  379.         }
  380.         if ($j == count($emailHistory)) {
  381.             return -1;
  382.         } else {
  383.             return $j;
  384.         }
  385.     }
  386.     /**
  387.      * Get the value of listOfmoderatorsLines
  388.      */
  389.     public function getListOfmoderatorsLines()
  390.     {
  391.         return $this->listOfmoderatorsLines;
  392.     }
  393.     /**
  394.      * Set the value of listOfmoderatorsLines
  395.      *
  396.      * @return  self
  397.      */
  398.     public function setListOfmoderatorsLines($listOfmoderatorsLines)
  399.     {
  400.         $this->listOfmoderatorsLines $listOfmoderatorsLines;
  401.         return $this;
  402.     }
  403.     public function getAllLines(): Collection
  404.     {
  405.         $list = new ArrayCollection();
  406.         $this->listOfauteursLines->forAll(function ($key$value) use (&$list) {
  407.             $list->add($value);
  408.             return true;
  409.         });
  410.         $this->listOfpresentateursLines->forAll(function ($key$value) use (&$list) {
  411.             $list->add($value);
  412.             return true;
  413.         });
  414.         $this->listOfmoderatorsLines->forAll(function ($key$value) use (&$list) {
  415.             $list->add($value);
  416.             return true;
  417.         });
  418.         return $list;
  419.     }
  420.     /**
  421.      * Get the value of moderator
  422.      */
  423.     public function isModerator(): ?bool
  424.     {
  425.         return $this->moderator;
  426.     }
  427.     /**
  428.      * Get the value of moderator
  429.      */
  430.     public function getModerator(): ?bool
  431.     {
  432.         return $this->moderator;
  433.     }
  434.     /**
  435.      * Set the value of moderator
  436.      *
  437.      * @return  self
  438.      */
  439.     public function setModerator(bool $moderator)
  440.     {
  441.         $this->moderator $moderator;
  442.         return $this;
  443.     }
  444.     public function getEvent(): ?Evenement
  445.     {
  446.         return $this->event;
  447.     }
  448.     public function setEvent(?Evenement $event): static
  449.     {
  450.         $this->event $event;
  451.         return $this;
  452.     }
  453.     public function isAuthor(): ?bool
  454.     {
  455.         return $this->is_author;
  456.     }
  457.     public function setIsAuthor(?bool $is_author): static
  458.     {
  459.         $this->is_author $is_author;
  460.         return $this;
  461.     }
  462.     public function isIsPresenter(): ?bool
  463.     {
  464.         return $this->is_presenter;
  465.     }
  466.     public function setIsPresenter(?bool $is_presenter): static
  467.     {
  468.         $this->is_presenter $is_presenter;
  469.         return $this;
  470.     }
  471.     public function isResponsable(): ?bool
  472.     {
  473.         return $this->is_responsable;
  474.     }
  475.     public function setIsResponsable(?bool $is_responsable): static
  476.     {
  477.         $this->is_responsable $is_responsable;
  478.         return $this;
  479.     }
  480.     public function isCommunauteScientifique(): ?bool
  481.     {
  482.         return $this->is_communaute_scientifique;
  483.     }
  484.     public function setIsCommunauteScientifique(?bool $is_communaute_scientifique): static
  485.     {
  486.         $this->is_communaute_scientifique $is_communaute_scientifique;
  487.         return $this;
  488.     }
  489.     public function isCommiteOrganisation(): ?bool
  490.     {
  491.         return $this->is_commite_organisation;
  492.     }
  493.     public function setIsCommiteOrganisation(?bool $is_commite_organisation): static
  494.     {
  495.         $this->is_commite_organisation $is_commite_organisation;
  496.         return $this;
  497.     }
  498.     public function  getUser()
  499.     {
  500.         return $this->user;
  501.     }
  502.     public function setUser(?User $user): void
  503.     {
  504.         $this->user $user;
  505.     }
  506.     /**
  507.      * Get the value of isConferencier
  508.      */
  509.     public function getIsConferencier()
  510.     {
  511.         return $this->is_conferencier;
  512.     }
  513.     /**
  514.      * Set the value of isConferencier
  515.      *
  516.      * @return  self
  517.      */
  518.     public function setIsConferencier($is_conferencier): static
  519.     {
  520.         $this->is_conferencier $is_conferencier;
  521.         return $this;
  522.     }
  523. }