src/Entity/MediaObject/MediaKnowledgeResponse.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity\MediaObject;
  3. use App\Entity\Knowledge\KnowledgeResponse;
  4. use App\Repository\MediaObject\MediaKnowledgeResponseRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\Serializer\Annotation\SerializedName;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use ApiPlatform\Core\Annotation\ApiResource;
  11. /**
  12.  * @ApiResource(
  13.  *     attributes={
  14.  *          "normalization_context"={"groups"={
  15.  *              "Knowledge:output"
  16.  *          }}
  17.  *      },
  18.  *     iri="http://schema.org/MediaKnowledgeResponse",
  19.  *     collectionOperations={
  20.  *         "get"
  21.  *     },
  22.  *     itemOperations={
  23.  *         "get"
  24.  *     }
  25.  * )
  26.  *
  27.  * @ORM\Entity(repositoryClass=MediaKnowledgeResponseRepository::class)
  28.  * @Vich\Uploadable()
  29.  */
  30. class MediaKnowledgeResponse extends MediaObject
  31. {
  32.     /**
  33.      * @ORM\OneToOne(targetEntity=KnowledgeResponse::class, mappedBy="image", cascade={"persist", "remove"})
  34.      */
  35.     private ?KnowledgeResponse $knowledgeResponse;
  36.     /**
  37.      * @var string|null
  38.      * @SerializedName("content_url")
  39.      * @Groups({"Knowledge:output"})
  40.      */
  41.     private ?string $contentUrl;
  42.     /**
  43.      * @var File|null
  44.      * @Vich\UploadableField(mapping="knowledge_response_image", fileNameProperty="filePath")
  45.      */
  46.     public ?File $file;
  47.     /**
  48.      * @var string|null
  49.      *
  50.      * @ORM\Column(nullable=true)
  51.      * @SerializedName("file_path")
  52.      * @Groups({"Knowledge:output"})
  53.      */
  54.     public $filePath;
  55.     public function getKnowledgeResponse(): ?KnowledgeResponse
  56.     {
  57.         return $this->knowledgeResponse;
  58.     }
  59.     public function setKnowledgeResponse(?KnowledgeResponse $knowledgeResponse): self
  60.     {
  61.         // unset the owning side of the relation if necessary
  62.         if ($knowledgeResponse === null && $this->knowledgeResponse !== null) {
  63.             $this->knowledgeResponse->setImage(null);
  64.         }
  65.         // set the owning side of the relation if necessary
  66.         if ($knowledgeResponse !== null && $knowledgeResponse->getImage() !== $this) {
  67.             $knowledgeResponse->setImage($this);
  68.         }
  69.         $this->knowledgeResponse $knowledgeResponse;
  70.         return $this;
  71.     }
  72.     public function getContentUrl(): ?string
  73.     {
  74.         return $this->contentUrl;
  75.     }
  76.     public function setContentUrl(?string $contentUrl): MediaKnowledgeResponse
  77.     {
  78.         $this->contentUrl $contentUrl;
  79.         return $this;
  80.     }
  81.     public function __toString(): string
  82.     {
  83.         return '';
  84.     }
  85. }