src/Entity/MediaObject/MediaPdfOdr.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Entity\MediaObject;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Operation\Odr;
  6. use App\Repository\MediaObject\MediaPdfOdrRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. /**
  14.  * @ApiResource(
  15.  *     attributes={
  16.  *          "normalization_context"={"groups"={
  17.  *              "media_object_read",
  18.  *              "MediaPdfOdr:output",
  19.  *              "MediaPdfOdr:io",
  20.  *              "OperationOdr:output",
  21.  *              "OperationMultiOffer:output",
  22.  *          }},
  23.  *          "denormalization_context"={"groups"={
  24.  *              "media_object_read",
  25.  *              "MediaPdfOdr:input",
  26.  *              "MediaPdfOdr:io",
  27.  *              "OperationOdr:input",
  28.  *              "OperationMultiOffer:input",
  29.  *          }}
  30.  *      },
  31.  *     iri="http://schema.org/MediaPdfOdr",
  32.  *     collectionOperations={
  33.  *         "get"
  34.  *     },
  35.  *     itemOperations={
  36.  *         "get"
  37.  *     }
  38.  * )
  39.  *
  40.  * @ORM\Entity(repositoryClass=MediaPdfOdrRepository::class)
  41.  * @Vich\Uploadable
  42.  */
  43. class MediaPdfOdr extends MediaObject
  44. {
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity=Odr::class, inversedBy="pdfOdrs", cascade={"persist"})
  47.      * @ORM\JoinColumn(nullable=true, name="object_id")
  48.      * @SerializedName("odr")
  49.      */
  50.     private $odr;
  51.     /**
  52.      * @var string|null
  53.      * @ApiProperty(iri="http://schema.org/contentUrl")
  54.      * @SerializedName("content_url")
  55.      * @Groups({
  56.      *     "MediaObject:output",
  57.      *     "MediaPdfOdr:output",
  58.      *     "media_object_read",
  59.      *     "OperationOdr:output",
  60.      * })
  61.      */
  62.     private $contentUrl;
  63.     /**
  64.      * @var File|null
  65.      * @Assert\NotNull(
  66.      *     groups={
  67.      *     "media_object_read",
  68.      *     "MediaPdfOdr:io",
  69.      *     "MediaObject:output",
  70.      *     "OperationMultiOffer:output",
  71.      * })
  72.      * @Vich\UploadableField(mapping="odr_image", fileNameProperty="filePath")
  73.      * @Groups({
  74.      *     "OperationOdr:output",
  75.      * })
  76.      */
  77.     public $file;
  78.     /**
  79.      * @var string|null
  80.      *
  81.      * @ORM\Column(nullable=true)
  82.      * @SerializedName("file_path")
  83.      * @Groups({
  84.      *     "OperationOdr:output",
  85.      *     "OperationMultiOffer:output",
  86.      * })
  87.      */
  88.     public $filePath;
  89.     /**
  90.      * @return mixed
  91.      */
  92.     public function getOdr()
  93.     {
  94.         return $this->odr;
  95.     }
  96.     public function setOdr($odr): MediaPdfOdr
  97.     {
  98.         $this->odr $odr;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return string|null
  103.      */
  104.     public function getContentUrl(): ?string
  105.     {
  106.         return $this->contentUrl;
  107.     }
  108.     /**
  109.      * @param string|null $contentUrl
  110.      * @return MediaPdfOdr
  111.      */
  112.     public function setContentUrl(?string $contentUrl): MediaPdfOdr
  113.     {
  114.         $this->contentUrl $contentUrl;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return string|null
  119.      */
  120.     public function __toString()
  121.     {
  122.         return "".$this->odr;
  123.     }
  124.     /**
  125.      * @return File|null
  126.      */
  127.     public function getFile(): ?File
  128.     {
  129.         return $this->file;
  130.     }
  131.     /**
  132.      * @param File|null $file
  133.      * @return MediaPdfOdr
  134.      */
  135.     public function setFile(?File $file): MediaPdfOdr
  136.     {
  137.         $this->file $file;
  138.         if ($file) {
  139.             $this->updatedAt = new \DateTime();
  140.         }
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return string|null
  145.      */
  146.     public function getFilePath(): ?string
  147.     {
  148.         return $this->filePath;
  149.     }
  150.     /**
  151.      * @param string|null $filePath
  152.      * @return MediaPdfOdr
  153.      */
  154.     public function setFilePath(?string $filePath): MediaPdfOdr
  155.     {
  156.         $this->filePath $filePath;
  157.         return $this;
  158.     }
  159. }