src/Entity/Participant.php line 13
<?php
namespace App\Entity;
use App\Entity\LineParticipant;
use App\Repository\ParticipantRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ParticipantRepository::class)]
class Participant
{
const TYPE_AUTEUR = 1;
const TYPE_PRESENTATEUR = 2;
const TYPE_MODERATOR = 3;
const TYPE_CONFERENCIER = 4;
const STATUS_DRAFT = 1;
const STATUS_VALID = 2;
const STATUS_FAILED = 3;
const STATUS_WAITING = 4;
const STATUS_REFUSED = 5; // ce status est ajouté pour le caas de refus d'administrateur
const STATUS_PAYMENT_PENDING = "Pending";
const STATUS_PAYMENT_SUCCESS = "Success";
const STATUS_PAYMENT_FAILED = "Failed";
const SEXE_HOMME = 1;
const SEXE_FEMME = 2;
// const CV_MARRIED = 1;
// const CV_SINGLE = 2;
const CV_MR = 1;
const CV_MME = 2;
const CV_MLLE = 3;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $firstname = null;
#[ORM\Column(length: 255)]
private ?string $lastname = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $mail = null;
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
private ?int $civility = null;
#[ORM\Column(type: 'datetime')]
private $createdAt;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updatedAt;
#[ORM\OneToOne(targetEntity: User::class, inversedBy: 'participant')]
#[ORM\JoinColumn(nullable: true)]
private ?User $user = null;
#[ORM\Column(nullable: true, options: ['default' => false])]
private ?bool $moderator = false;
#[ORM\Column(type: Types::SMALLINT)]
private ?int $status = null;
/**
* @deprecated
*/
#[ORM\Column(type: Types::SMALLINT)]
private ?int $type = null;
/** @var LineParticipant[]|ArrayCollection|Collection<int,LineParticipant> */
#[ORM\ManyToMany(targetEntity: LineParticipant::class, mappedBy: 'participants', cascade: ["persist"])] // , "remove"
# [ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private Collection $lineParticipants;
/** @var Line[]|ArrayCollection|Collection<int,Line> */
#[ORM\ManyToMany(targetEntity: Line::class, mappedBy: 'listOfpresentateurs')]
private Collection $listOfpresentateursLines;
/** @var Line[]|ArrayCollection|Collection<int,Line> */
#[ORM\ManyToMany(targetEntity: Line::class, mappedBy: 'listOfauteurs')]
private Collection $listOfauteursLines;
/** @var Line[]|ArrayCollection|Collection<int,Line> */
#[ORM\ManyToMany(targetEntity: Line::class, mappedBy: 'listOfmoderators')]
private Collection $listOfmoderatorsLines;
private $listOfAuteurLineId = [];
private $listOfPresentateurLineId = [];
#[ORM\Column(nullable: true)]
private ?array $email_history = null;
#[ORM\ManyToOne(inversedBy: 'participants')]
private ?Evenement $event = null;
#[ORM\Column(nullable: true)]
private ?bool $is_author = null;
#[ORM\Column(nullable: true)]
private ?bool $is_presenter = null;
#[ORM\Column(nullable: true)]
private ?bool $is_conferencier = null;
#[ORM\Column(nullable: true)]
private ?bool $is_responsable = null;
#[ORM\Column(nullable: true)]
private ?bool $is_communaute_scientifique = null;
#[ORM\Column(nullable: true)]
private ?bool $is_commite_organisation = null;
public function __construct()
{
$this->listOfpresentateursLines = new ArrayCollection();
$this->listOfauteursLines = new ArrayCollection();
$this->lineParticipants = new ArrayCollection();
$this->listOfmoderatorsLines = new ArrayCollection();
$this->moderator = false;
}
public function __toString(): string
{
return $this->getFullname();
}
public function getFullname(): string
{
return trim($this->firstname . ' ' . $this->lastname);
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getMail(): ?string
{
if ($this->mail) {
return $this->mail;
}
return $this->user?->getEmail();
}
/**
* Set the value of mail
*/
public function setmail(?string $mail, bool $updateUser = false): self
{
$this->mail = $mail;
if ($this->user && $updateUser) {
$this->user->setEmail($mail);
}
return $this;
}
public function getTitle(): ?string
{
return $this->user?->getTitle();
}
public function getCivility(): ?int
{
if ($this->user) {
if (is_null($this->user->getCivility())) {
if ($this->user->getSexe() == self::SEXE_HOMME) {
$this->user->setCivility(self::CV_MR);
} elseif ($this->user->getSexe() == self::SEXE_FEMME) {
$this->user->setCivility(self::CV_MME);
}
}
return $this->user->getCivility();
}
return $this->civility;
}
public function setCivility(int $civility): self
{
$this->civility = $civility;
if($this->user) {
$this->user->setCivility($civility);
}
return $this;
}
public function getSexe(): ?int
{
return $this->user?->getSexe();
}
public function getCountry(): ?string
{
return $this->user?->getCountry();
}
public function getAdresse(): ?string
{
return $this->user?->getAdresse();
}
public function getCity(): ?string
{
return $this->user?->getCity();
}
public function getPostalCode(): ?int
{
return $this->user?->getPostalCode();
}
public function getWorkplace(): ?string
{
return $this->user?->getWorkplace();
}
public function getMobile(): ?string
{
return $this->user?->getMobile();
}
public function getPhone(): ?string
{
return $this->user?->getPhone();
}
public function getSpeciality(): ?string
{
return $this->user?->getSpeciality();
}
public function getActivity(): ?string
{
return $this->user?->getActivity();
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function isStatus(): ?bool
{
return $this->status;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
/**
* @deprecated
*
* @return integer|null
*/
public function getType(): ?int
{
return $this->type;
}
/**
* @deprecated
*
* @param integer $type
* @return self
*/
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, Line>
*/
public function getListOfpresentateursLines(): Collection
{
return $this->listOfpresentateursLines;
}
public function addListOfpresentateursLine(Line $listOfpresentateursLine): self
{
if (!$this->listOfpresentateursLines->contains($listOfpresentateursLine)) {
$this->listOfpresentateursLines->add($listOfpresentateursLine);
$listOfpresentateursLine->addListOfpresentateur($this);
}
return $this;
}
public function removeListOfpresentateursLine(Line $listOfpresentateursLine): self
{
if ($this->listOfpresentateursLines->removeElement($listOfpresentateursLine)) {
$listOfpresentateursLine->removeListOfpresentateur($this);
}
return $this;
}
/**
* @return Collection<int,Line>|Line[]
*/
public function getListOfauteursLines(): Collection
{
return $this->listOfauteursLines;
}
/**
* returns an array of the ids of lines where participant is an author
* @param int $eventId (optional) specify from which event to collect lines
* @return array
*/
public function getListofAuteurLinesId($eventId = null): array
{
$data = [];
/** @var Line $line */
foreach ($this->listOfauteursLines as $line) {
if ($eventId != null) {
//collect only lines corresponding to $eventId
if ($eventId == $line->getEvenement()->getId()) {
$data[] = $line->getId();
}
} else {
//collect lines for all events
$data[] = $line->getId();
}
}
$this->listOfAuteurLineId = $data;
return $data;
}
public function addListOfauteursLine(Line $listOfauteursLine): self
{
if (!$this->listOfauteursLines->contains($listOfauteursLine)) {
$this->listOfauteursLines->add($listOfauteursLine);
$listOfauteursLine->addListOfauteur($this);
}
return $this;
}
public function removeListOfauteursLine(Line $listOfauteursLine): self
{
if ($this->listOfauteursLines->removeElement($listOfauteursLine)) {
$listOfauteursLine->removeListOfauteur($this);
}
return $this;
}
/**
* Get the value of lineParticipants
*/
public function getLineParticipants(): ?Collection
{
return $this->lineParticipants;
}
/**
* Set the value of lineParticipants
*
* @return self
*/
public function setLineParticipants(?Collection $lineParticipants): self
{
$this->lineParticipants = $lineParticipants;
return $this;
}
public function addLineParticipant(LineParticipant $lineParticipant): void
{
if (!$this->lineParticipants->contains($lineParticipant)) {
$this->lineParticipants->add($lineParticipant);
}
}
public function removeLineParticipant(LineParticipant $lineParticipant): void
{
if (!$this->lineParticipants->contains($lineParticipant)) {
$this->lineParticipants->removeElement($lineParticipant);
}
}
public function getEmailHistory(): ?array
{
return $this->email_history;
}
public function setEmailHistory(?array $email_history): static
{
$this->email_history = $email_history;
return $this;
}
public function getEmailHistoryWTheme(string $theme)
{
$j = 0;
$emailHistory = $this->getEmailHistory();
if ($emailHistory) {
foreach ($emailHistory as $email) {
if ($email['theme'] == $theme) {
break;
}
$j++;
}
}
if ($j == count($emailHistory)) {
return -1;
} else {
return $j;
}
}
/**
* Get the value of listOfmoderatorsLines
*/
public function getListOfmoderatorsLines()
{
return $this->listOfmoderatorsLines;
}
/**
* Set the value of listOfmoderatorsLines
*
* @return self
*/
public function setListOfmoderatorsLines($listOfmoderatorsLines)
{
$this->listOfmoderatorsLines = $listOfmoderatorsLines;
return $this;
}
public function getAllLines(): Collection
{
$list = new ArrayCollection();
$this->listOfauteursLines->forAll(function ($key, $value) use (&$list) {
$list->add($value);
return true;
});
$this->listOfpresentateursLines->forAll(function ($key, $value) use (&$list) {
$list->add($value);
return true;
});
$this->listOfmoderatorsLines->forAll(function ($key, $value) use (&$list) {
$list->add($value);
return true;
});
return $list;
}
/**
* Get the value of moderator
*/
public function isModerator(): ?bool
{
return $this->moderator;
}
/**
* Get the value of moderator
*/
public function getModerator(): ?bool
{
return $this->moderator;
}
/**
* Set the value of moderator
*
* @return self
*/
public function setModerator(bool $moderator)
{
$this->moderator = $moderator;
return $this;
}
public function getEvent(): ?Evenement
{
return $this->event;
}
public function setEvent(?Evenement $event): static
{
$this->event = $event;
return $this;
}
public function isAuthor(): ?bool
{
return $this->is_author;
}
public function setIsAuthor(?bool $is_author): static
{
$this->is_author = $is_author;
return $this;
}
public function isIsPresenter(): ?bool
{
return $this->is_presenter;
}
public function setIsPresenter(?bool $is_presenter): static
{
$this->is_presenter = $is_presenter;
return $this;
}
public function isResponsable(): ?bool
{
return $this->is_responsable;
}
public function setIsResponsable(?bool $is_responsable): static
{
$this->is_responsable = $is_responsable;
return $this;
}
public function isCommunauteScientifique(): ?bool
{
return $this->is_communaute_scientifique;
}
public function setIsCommunauteScientifique(?bool $is_communaute_scientifique): static
{
$this->is_communaute_scientifique = $is_communaute_scientifique;
return $this;
}
public function isCommiteOrganisation(): ?bool
{
return $this->is_commite_organisation;
}
public function setIsCommiteOrganisation(?bool $is_commite_organisation): static
{
$this->is_commite_organisation = $is_commite_organisation;
return $this;
}
public function getUser()
{
return $this->user;
}
public function setUser(?User $user): void
{
$this->user = $user;
}
/**
* Get the value of isConferencier
*/
public function getIsConferencier()
{
return $this->is_conferencier;
}
/**
* Set the value of isConferencier
*
* @return self
*/
public function setIsConferencier($is_conferencier): static
{
$this->is_conferencier = $is_conferencier;
return $this;
}
}