src/Entity/LineParticipant.php line 12
<?phpnamespace App\Entity;use App\Repository\LineParticipantRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: LineParticipantRepository::class)]class LineParticipant{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $description = null;#[ORM\Column(type: Types::INTEGER, nullable: true, options: ['default' => 0])]private ?int $position = 0;#[ORM\ManyToOne(targetEntity: Line::class, inversedBy: 'lineParticipants', cascade: ["persist"])]// , "remove"#[ORM\JoinColumn(nullable: true)]private ?Line $line;/** @var Participant[]|ArrayCollection|Collection<int,Participant> */#[ORM\ManyToMany(targetEntity: Participant::class, inversedBy: 'lineParticipants', cascade: ["persist"])] // , "remove"#[ORM\JoinTable(name: 'line_participant_participant')]#[ORM\JoinColumn(nullable: true, onDelete: "RESTRICT")]#[ORM\InverseJoinColumn(nullable: true, onDelete: "RESTRICT")]private $participants;public function __construct(){$this->description = null;$this->line = null;$this->position = 0;$this->participants = new ArrayCollection();}public function getInfos(): string{return $this->description . ($this->line ? ' ' . $this->line->getTheme() : '');}public function getId(): ?int{return $this->id;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}/*** Get the value of the line under which the presentation is held*/public function getLine(): ?Line{return $this->line;}/*** Set the value of line** @return self*/public function setLine(?Line $line): self{$this->line = $line;return $this;}public function getListParticipants(): string{$list = [];if ($this->participants) {foreach ($this->participants as $participant) {if ($participant && $participant->getFullname()) {$list[] = $participant->getFullname();}}if ($list) {return implode(" / ", $list);}}return "";}/*** returns an array of the ids of presenters* @param int $event_id (optional) specify from which event to collect lines* @return array*/public function getListParticipantId($event_id = null){$list = [];foreach ($this->participants as $participant) {if ($event_id != null) {//collect only lines corresponding to $eventIdif ($this->getLine()->getEvenement()->getId() == $event_id) {$list[] = $participant->getId();}} else {//collect lines for all events$list[] = $participant->getId();}}return $list;}/*** Get the value of participant*/public function getParticipants(){return $this->participants;}/*** Set the value of participant** @return self*/public function setParticipants($participants): self{$this->participants = $participants;return $this;}public function addParticipant(Participant $participant): void{if (!$this->participants->contains($participant)) {$participant->addLineParticipant($this);$this->participants->add($participant);}}public function removeParticipant(Participant $participant): void{if ($this->participants->contains($participant)) {$participant->removeLineParticipant($this);$this->participants->removeElement($participant);}}}