src/Entity/MediaObject/MediaRecipe.php line 42

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 Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Serializer\Annotation\SerializedName;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12.  * @ApiResource(
  13.  *     attributes={
  14.  *          "normalization_context"={"groups"={
  15.  *              "media_object_read",
  16.  *              "MediaRecipe:output",
  17.  *              "MediaRecipe:io",
  18.  *              "Recipe:io",
  19.  *          }},
  20.  *          "denormalization_context"={"groups"={
  21.  *              "media_object_read",
  22.  *              "MediaRecipe:input",
  23.  *              "MediaRecipe:io",
  24.  *              "Recipe:io",
  25.  *          }}
  26.  *      },
  27.  *     iri="http://schema.org/MediaRecipe",
  28.  *     collectionOperations={
  29.  *         "get"
  30.  *     },
  31.  *     itemOperations={
  32.  *         "get"
  33.  *     }
  34.  * )
  35.  *
  36.  * @ORM\Entity(repositoryClass=MediaRecipe::class)
  37.  * @Vich\Uploadable
  38.  */
  39. class MediaRecipe extends MediaObject
  40. {
  41.     /**
  42.      * @Assert\NotNull(
  43.      *     groups={
  44.      *     "media_object_read",
  45.      *     "MediaRecipe:io",
  46.      *     "MediaObject:output",
  47.      *     "Recipe:io",
  48.      * })
  49.      * @Vich\UploadableField(mapping="recipe", fileNameProperty="filePath")
  50.      */
  51.     public ?File $file null;
  52.     /**
  53.      * @var string|null
  54.      *
  55.      * @ORM\Column(nullable=true)
  56.      * @SerializedName("file_path")
  57.      * @Groups({
  58.      *     "MediaRecipe:output",
  59.      *     "Recipe:io",
  60.      * })
  61.      */
  62.     public $filePath;
  63.     /**
  64.      * @var string|null
  65.      * @ApiProperty(iri="http://schema.org/contentUrl")
  66.      * @Groups({
  67.      *     "MediaObject:output",
  68.      *     "MediaRecipe:output",
  69.      *     "Recipe:io",
  70.      * })
  71.      */
  72.     private ?string $contentUrl;
  73.     /**
  74.      * @return string|null
  75.      */
  76.     public function getContentUrl(): ?string
  77.     {
  78.         return $this->contentUrl;
  79.     }
  80.     /**
  81.      * @param string|null $contentUrl
  82.      * @return MediaRecipe
  83.      */
  84.     public function setContentUrl(?string $contentUrl): MediaRecipe
  85.     {
  86.         $this->contentUrl $contentUrl;
  87.         return $this;
  88.     }
  89.     /**
  90.      * @return File|null
  91.      */
  92.     public function getFile(): ?File
  93.     {
  94.         return $this->file;
  95.     }
  96.     /**
  97.      * @param File|null $file
  98.      * @return MediaRecipe
  99.      */
  100.     public function setFile(?File $file): MediaRecipe
  101.     {
  102.         $this->file $file;
  103.         if ($file) {
  104.             $this->updatedAt = new \DateTime();
  105.         }
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return string|null
  110.      */
  111.     public function getFilePath(): ?string
  112.     {
  113.         return $this->filePath;
  114.     }
  115.     /**
  116.      * @param string|null $filePath
  117.      * @return MediaRecipe
  118.      */
  119.     public function setFilePath(?string $filePath): MediaRecipe
  120.     {
  121.         $this->filePath $filePath;
  122.         return $this;
  123.     }
  124. }