src/Entity/EventAbstract.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EventAbstractRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassEventAbstractRepository::class)]
  9. class EventAbstract
  10. {
  11.     //decisions
  12.     const COMMUNICATION_ORALE 1;
  13.     const COMMUNICATION_ECRITE 2;
  14.     const POSTER_COMMENTE 3;
  15.     const POSTER_ELECTRONIQUE 4;
  16.     //types
  17.     const COMMUNICATION 1;
  18.     const POSTER 2;
  19.     //statut
  20.     const ACCEPTED 1;
  21.     const REFUSED 2;
  22.     const PENDING 3;
  23.     const DRAFT 4;
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     private ?int $id null;
  28.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  29.     private ?int $type null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $title null;
  32.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  33.     private ?string $intro null;
  34.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  35.     private ?string $objectifs null;
  36.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  37.     private ?string $methodes null;
  38.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  39.     private ?string $result null;
  40.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  41.     private ?string $conclusion null;
  42.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  43.     private ?int $status null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?int $updated_by null;
  46.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  47.     private ?\DateTimeInterface $created_at null;
  48.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  49.     private ?\DateTimeInterface $updated_at null;
  50.     #[ORM\ManyToOne(inversedBy'eventAbstracts')]
  51.     #[ORM\JoinColumn(nullabletrue)]
  52.     private ?Evenement $event null;
  53.     # [ORM\ManyToOne(targetEntity: Theme::class, inversedBy: 'eventAbstract')]
  54.     private ?Theme $theme null;
  55.     #[ORM\ManyToMany(targetEntityTheme::class, inversedBy'eventAbstracts')]
  56.     #[ORM\JoinTable(name"event_abstract_themes")]
  57.     private Collection $themes;
  58.     #[ORM\ManyToOne(targetEntityAbstractAuthors::class, inversedBy'eventAbstract')]
  59.     # [ORM\JoinTable(name: "event_abstract_responsible")]
  60.     private ?AbstractAuthors $responsable null;
  61.     #[ORM\ManyToMany(targetEntityAbstractAuthors::class, inversedBy'eventAbstractsAsPresenter'cascade: ["persist""remove"])]
  62.     #[ORM\JoinTable(name"event_abstract_as_presenters")]
  63.     private Collection $presenters;
  64.     #[ORM\ManyToMany(targetEntityAbstractAuthors::class, inversedBy'eventAbstractsAsAuthors'cascade: ["persist""remove"])]
  65.     #[ORM\JoinTable(name"event_abstract_as_authors")]
  66.     private Collection $authors;
  67.     #[ORM\Column(length255nullabletrue)]
  68.     private ?string $reference null;
  69.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'eventAbstracts')]
  70.     #[ORM\JoinColumn(nullabletrue)]
  71.     private ?User $user null;
  72.     #[ORM\Column(length255nullabletrue)]
  73.     private ?int $decision null;
  74.     public function __construct()
  75.     {
  76.         $this->themes = new ArrayCollection();
  77.         $this->presenters = new ArrayCollection();
  78.         $this->created_at = new \DateTime();
  79.         $this->status self::DRAFT;
  80.         $this->authors = new ArrayCollection();
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getType(): ?int
  87.     {
  88.         return $this->type;
  89.     }
  90.     public function setType(?int $type): static
  91.     {
  92.         $this->type $type;
  93.         return $this;
  94.     }
  95.     public function getTitle(): ?string
  96.     {
  97.         return $this->title;
  98.     }
  99.     public function setTitle(?string $title): static
  100.     {
  101.         $this->title $title;
  102.         return $this;
  103.     }
  104.     public function getIntro(): ?string
  105.     {
  106.         return $this->intro;
  107.     }
  108.     public function setIntro(?string $intro): static
  109.     {
  110.         $this->intro $intro;
  111.         return $this;
  112.     }
  113.     public function getObjectifs(): ?string
  114.     {
  115.         return $this->objectifs;
  116.     }
  117.     public function setObjectifs(?string $objectifs): static
  118.     {
  119.         $this->objectifs $objectifs;
  120.         return $this;
  121.     }
  122.     public function getMethodes(): ?string
  123.     {
  124.         return $this->methodes;
  125.     }
  126.     public function setMethodes(?string $methodes): static
  127.     {
  128.         $this->methodes $methodes;
  129.         return $this;
  130.     }
  131.     public function getResult(): ?string
  132.     {
  133.         return $this->result;
  134.     }
  135.     public function setResult(?string $result): static
  136.     {
  137.         $this->result $result;
  138.         return $this;
  139.     }
  140.     public function getConclusion(): ?string
  141.     {
  142.         return $this->conclusion;
  143.     }
  144.     public function setConclusion(?string $conclusion): static
  145.     {
  146.         $this->conclusion $conclusion;
  147.         return $this;
  148.     }
  149.     public function getStatus(): ?int
  150.     {
  151.         return $this->status;
  152.     }
  153.     public function setStatus(?int $status): static
  154.     {
  155.         $this->status $status;
  156.         return $this;
  157.     }
  158.     public function getUpdatedBy(): ?int
  159.     {
  160.         return $this->updated_by;
  161.     }
  162.     public function setUpdatedBy(?int $updated_by): static
  163.     {
  164.         $this->updated_by $updated_by;
  165.         return $this;
  166.     }
  167.     public function getCreatedAt(): ?\DateTimeInterface
  168.     {
  169.         return $this->created_at;
  170.     }
  171.     public function setCreatedAt(?\DateTimeInterface $created_at): static
  172.     {
  173.         $this->created_at $created_at;
  174.         return $this;
  175.     }
  176.     public function getUpdatedAt(): ?\DateTimeInterface
  177.     {
  178.         return $this->updated_at;
  179.     }
  180.     public function setUpdatedAt(?\DateTimeInterface $updated_at): static
  181.     {
  182.         $this->updated_at $updated_at;
  183.         return $this;
  184.     }
  185.     public function getEvenement(): ?Evenement
  186.     {
  187.         return $this->event;
  188.     }
  189.     public function setEvenement(?Evenement $event): static
  190.     {
  191.         $this->event $event;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @deprecated
  196.      */
  197.     public function getEvent(): ?Evenement
  198.     {
  199.         return $this->event;
  200.     }
  201.     /**
  202.      * @deprecated
  203.      */
  204.     public function setEvent(?Evenement $event): static
  205.     {
  206.         $this->event $event;
  207.         return $this;
  208.     }
  209.     public function getTheme(): ?Theme
  210.     {
  211.         // if (empty($this->theme) && !$this->themes->isEmpty()) {
  212.         //     return $this->themes->first();
  213.         // }
  214.         return $this->theme;
  215.     }
  216.     public function setTheme(?Theme $theme): static
  217.     {
  218.         $this->theme $theme;
  219.         return $this;
  220.     }
  221.     public function getThemes(): Collection
  222.     {
  223.         return $this->themes;
  224.     }
  225.     public function addTheme(?Theme $theme): static
  226.     {
  227.         if (!$this->themes->contains($theme)) {
  228.             $this->themes->add($theme);
  229.             $theme->addEventAbstract($this);
  230.         }
  231.         return $this;
  232.     }
  233.     public function removeTheme(?Theme $theme): static
  234.     {
  235.         if ($this->themes->removeElement($theme)) {
  236.             $theme->removeEventAbstract($this);
  237.         }
  238.         return $this;
  239.     }
  240.     public function getResponsable(): ?AbstractAuthors
  241.     {
  242.         return $this->responsable;
  243.     }
  244.     public function setResponsable(?AbstractAuthors $responsable): static
  245.     {
  246.         $this->responsable $responsable;
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return Collection<int, AbstractAuthors>
  251.      */
  252.     public function getPresenters(): Collection
  253.     {
  254.         return $this->presenters;
  255.     }
  256.     public function addPresenter(AbstractAuthors $presenter): static
  257.     {
  258.         if (!$this->presenters->contains($presenter)) {
  259.             $this->presenters->add($presenter);
  260.         }
  261.         return $this;
  262.     }
  263.     public function removePresenter(AbstractAuthors $presenter): static
  264.     {
  265.         $this->presenters->removeElement($presenter);
  266.         return $this;
  267.     }
  268.     public function getReference(): ?string
  269.     {
  270.         return $this->reference;
  271.     }
  272.     public function setReference(?string $reference): static
  273.     {
  274.         $this->reference $reference;
  275.         return $this;
  276.     }
  277.     /**
  278.      * Cette fonction sert à générer une référence pour un abstract selon son type
  279.      * @return string
  280.      */
  281.     public function generateReference(): string
  282.     {
  283.         //get original occurrence
  284.         $compteurs $this->getEvenement()->getCompteurs();
  285.         if (!isset($compteurs[$this->decision])) {
  286.             $compteurs[$this->decision] = 1;
  287.         }
  288.         $occ $compteurs[$this->decision];
  289.         //update compteurs in event
  290.         $occ++;
  291.         $this->getEvenement()->modifyCompteurs($this->decision$occ);
  292.         //generate the reference
  293.         return match ($this->decision) {
  294.             self::COMMUNICATION_ORALE => "CO" $occ,
  295.             self::COMMUNICATION_ECRITE => "CE" $occ,
  296.             self::POSTER_COMMENTE =>   "PC" $occ,
  297.             self::POSTER_ELECTRONIQUE => "PE" $occ,
  298.             default => "PO" $occ// self::POSTER
  299.         };
  300.     }
  301.     public function getUser(): ?User
  302.     {
  303.         return $this->user;
  304.     }
  305.     public function setUser(?User $user): static
  306.     {
  307.         $this->user $user;
  308.         return $this;
  309.     }
  310.     /**
  311.      * @return Collection<int, AbstractAuthors>
  312.      */
  313.     public function getAuthors(): ?Collection
  314.     {
  315.         return $this->authors;
  316.     }
  317.     public function addAuthor(AbstractAuthors $author): void
  318.     {
  319.         if (!$this->authors->contains($author)) {
  320.             $this->authors->add($author);
  321.         }
  322.     }
  323.     public function removeAuthor(AbstractAuthors $author): void
  324.     {
  325.         if ($this->presenters->contains($author)) {
  326.             $this->removePresenter($author);
  327.         }
  328.         if ($this->responsable == $author) {
  329.             $this->setResponsable(null);
  330.         }
  331.         $this->authors->removeElement($author);
  332.     }
  333.     public function getDecision(): ?int
  334.     {
  335.         return $this->decision;
  336.     }
  337.     public function setDecision(?int $decision): static
  338.     {
  339.         $this->decision $decision;
  340.         return $this;
  341.     }
  342.     public function getDecisionName(): string
  343.     {
  344.         switch ($this->decision) {
  345.             case self::COMMUNICATION_ORALE:
  346.                 $dec "Communication Orale";
  347.                 break;
  348.             case self::COMMUNICATION_ECRITE:
  349.                 $dec "Communication Ecrite";
  350.                 break;
  351.             case self::POSTER_COMMENTE:
  352.                 $dec "Poster Commenté";
  353.                 break;
  354.             case self::POSTER_ELECTRONIQUE:
  355.                 $dec "Poster Electronique";
  356.                 break;
  357.             default:
  358.                 $dec "";
  359.                 break;
  360.         }
  361.         return $dec;
  362.     }
  363. }