src/Entity/Knowledge/KnowledgeResponse.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Knowledge;
  3. use App\Entity\MediaObject\MediaKnowledgeResponse;
  4. use App\Repository\Knowledge\KnowledgeResponseRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Ramsey\Uuid\Doctrine\UuidGenerator;
  7. use Ramsey\Uuid\Uuid;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Serializer\Annotation\SerializedName;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use ApiPlatform\Core\Annotation\ApiResource;
  13. /**
  14.  * @ApiResource(
  15.  *     attributes={
  16.  *          "normalization_context"={"groups"={
  17.  *              "Knowledge:output"
  18.  *          }}
  19.  *      },
  20.  *     iri="http://schema.org/KnowledgeResponse",
  21.  *     collectionOperations={
  22.  *         "get"
  23.  *     },
  24.  *     itemOperations={
  25.  *         "get"
  26.  *     }
  27.  * )
  28.  *
  29.  * @ORM\Entity(repositoryClass=KnowledgeResponseRepository::class)
  30.  * @Vich\Uploadable()
  31.  */
  32. class KnowledgeResponse
  33. {
  34.     /**
  35.      * @ORM\Id
  36.      * @ORM\Column(type="uuid", unique=true)
  37.      * @ORM\GeneratedValue(strategy="CUSTOM")
  38.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  39.      * @SerializedName("id")
  40.      * @Groups({"Knowledge:output"})
  41.      */
  42.     private string $id;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      * @Groups({"Knowledge:output"})
  46.      */
  47.     private ?string $text;
  48.     /**
  49.      * @ORM\OneToOne(targetEntity=MediaKnowledgeResponse::class, inversedBy="knowledgeResponse", cascade={"persist", "remove"})
  50.      * @Groups({"Knowledge:output"})
  51.      */
  52.     private ?MediaKnowledgeResponse $image null;
  53.     public ?File $file null;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=Knowledge::class, inversedBy="knowledgeResponses")
  56.      */
  57.     private ?Knowledge $knowledge;
  58.     /**
  59.      * @ORM\Column(type="integer", nullable=true)
  60.      * @Groups({"Knowledge:output"})
  61.      */
  62.     private ?int $position null;
  63.     public function __construct()
  64.     {
  65.         $this->id Uuid::uuid4();
  66.     }
  67.     public function getId(): ?string
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getText(): ?string
  72.     {
  73.         return $this->text;
  74.     }
  75.     public function setText(?string $text): self
  76.     {
  77.         $this->text $text;
  78.         return $this;
  79.     }
  80.     public function getImage(): ?MediaKnowledgeResponse
  81.     {
  82.         return $this->image;
  83.     }
  84.     public function setImage(?MediaKnowledgeResponse $image): self
  85.     {
  86.         $this->image $image;
  87.         return $this;
  88.     }
  89.     public function getKnowledge(): ?Knowledge
  90.     {
  91.         return $this->knowledge;
  92.     }
  93.     public function setKnowledge(?Knowledge $knowledge): self
  94.     {
  95.         $this->knowledge $knowledge;
  96.         return $this;
  97.     }
  98.     public function getPosition(): ?int
  99.     {
  100.         return $this->position;
  101.     }
  102.     public function setPosition(?int $position): self
  103.     {
  104.         $this->position $position;
  105.         return $this;
  106.     }
  107. }