<?php namespace App\Entity; use App\Repository\QuizzRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=QuizzRepository::class) */ class Quizz { //Quizz is not viewable by users const STATUS_CLOSED = 0; //Quizz is answerable ( = writable) const STATUS_OPENED = 1; //Quizz is viewable ( = read only) const STATUS_FINISHED = 2; const STATUS = [ 'fermé' => 0, 'ouvert' => 1, 'terminé' => 2, ]; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="text") */ private $description; /** * @ORM\Column(type="boolean", nullable=true) */ private $isRandom; /** * @ORM\Column(type="integer",options={"default":0}) */ private $status = 0; /** * @ORM\OneToMany(targetEntity=Question::class, mappedBy="quizz", cascade={"remove", "persist"}) */ private $questions; public function __construct() { $this->questions = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName( string $name ): self { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription( string $description ): self { $this->description = $description; return $this; } public function getIsRandom(): ?bool { return $this->isRandom; } public function setIsRandom( ?bool $isRandom ): self { $this->isRandom = $isRandom; return $this; } public function getStatus(): ?int { return $this->status; } public function setStatus( int $status ): self { $this->status = $status; return $this; } /** * @return Collection|Question[] */ public function getQuestions(): Collection { return $this->questions; } public function addQuestion( Question $question ): self { if ( !$this->questions->contains( $question ) ) { $this->questions[] = $question; $question->setQuizz( $this ); } return $this; } public function removeQuestion( Question $question ): self { if ( $this->questions->removeElement( $question ) ) { // set the owning side to null (unless already changed) if ( $question->getQuizz() === $this ) { $question->setQuizz( NULL ); } } return $this; } }