src/Entity/MediaObject/MediaProduct.php line 71

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\Controller\Api\MediaObject\CreateMediaProductAction;
  6. use App\Entity\Participation\Puntos;
  7. use App\Repository\MediaObject\MediaProductRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Serializer\Annotation\SerializedName;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. /**
  15.  * @ApiResource(
  16.  *     attributes={
  17.  *          "normalization_context"={"groups"={
  18.  *              "media_object_read",
  19.  *              "MediaProduct:io",
  20.  *              "MediaProduct:output",
  21.  *          }},
  22.  *          "denormalization_context"={"groups"={
  23.  *              "media_object_read",
  24.  *              "MediaProduct:io",
  25.  *              "MediaProduct:input",
  26.  *              "get_participation-steps_by_user",
  27.  *          }}
  28.  *      },
  29.  *     iri="http://schema.org/MediaProduct",
  30.  *     collectionOperations={
  31.  *         "post"={
  32.  *             "controller"=CreateMediaProductAction::class,
  33.  *             "deserialize"=false,
  34.  *             "security"="is_granted('ROLE_USER')",
  35.  *             "validation_groups"={
  36.  *                  "Default",
  37.  *                  "media_object_create",
  38.  *                  "MediaProduct:io",
  39.  *              },
  40.  *             "openapi_context"={
  41.  *                 "requestBody"={
  42.  *                     "content"={
  43.  *                         "multipart/form-data"={
  44.  *                             "schema"={
  45.  *                                 "type"="object",
  46.  *                                 "properties"={
  47.  *                                     "file"={
  48.  *                                         "type"="string",
  49.  *                                         "format"="binary"
  50.  *                                     }
  51.  *                                 }
  52.  *                             }
  53.  *                         }
  54.  *                     }
  55.  *                 }
  56.  *             }
  57.  *         },
  58.  *         "get"
  59.  *     },
  60.  *     itemOperations={
  61.  *         "get"
  62.  *     }
  63.  * )
  64.  *
  65.  * @ORM\Entity(repositoryClass=MediaProductRepository::class)
  66.  * @Vich\Uploadable
  67.  */
  68. class MediaProduct extends MediaObject
  69. {
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity=Puntos::class, inversedBy="products")
  72.      * @ORM\JoinColumn(nullable=true, name="object_id")
  73.      * @SerializedName("participation")
  74.      * @Groups({
  75.      *     "MediaProduct:output",
  76.      *     "MediaObject:output",
  77.      * })
  78.      */
  79.     private $participation;
  80.     /**
  81.      * @var string|null
  82.      * @ApiProperty(iri="http://schema.org/contentUrl")
  83.      * @SerializedName("content_url")
  84.      * @Groups({
  85.      *     "media_object_read",
  86.      *     "MediaProduct:io",
  87.      *     "MediaObject:io",
  88.      *     "ParticipationPuntos:output",
  89.      * })
  90.      */
  91.     private $contentUrl;
  92.     /**
  93.      * @var File|null
  94.      *
  95.      * @Assert\NotNull(
  96.      *     groups={
  97.      *     "media_object_read",
  98.      *     "MediaObject:output",
  99.      * })
  100.      * @Vich\UploadableField(mapping="media_object", fileNameProperty="filePath")
  101.      */
  102.     public $file;
  103.     /**
  104.      * @var string|null
  105.      *
  106.      * @ORM\Column(nullable=true)
  107.      * @SerializedName("file_path")
  108.      * @Groups({
  109.      *     "media_object_read",
  110.      *     "MediaProduct:io",
  111.      *     "MediaObject:io",
  112.      *     "ParticipationPuntos:output",
  113.      * })
  114.      */
  115.     public $filePath;
  116.     public function getParticipation()
  117.     {
  118.         return $this->participation;
  119.     }
  120.     public function setParticipation($participation)
  121.     {
  122.         $this->participation $participation;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return string|null
  127.      */
  128.     public function getContentUrl(): ?string
  129.     {
  130.         return $this->contentUrl;
  131.     }
  132.     /**
  133.      * @param string|null $contentUrl
  134.      * @return MediaProduct
  135.      */
  136.     public function setContentUrl(?string $contentUrl): MediaProduct
  137.     {
  138.         $this->contentUrl $contentUrl;
  139.         return $this;
  140.     }
  141. }