<?php
namespace App\Entity\MediaObject;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\MediaObject\MediaPdfRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={
* "media_object_read",
* "MediaPdf:output",
* "MediaPdf:io",
* }},
* "denormalization_context"={"groups"={
* "media_object_read",
* "MediaPdf:input",
* "MediaPdf:io",
* }}
* },
* iri="http://schema.org/MediaPdf",
* collectionOperations={
* "get"
* },
* itemOperations={
* "get"
* }
* )
*
* @ORM\Entity(repositoryClass=MediaPdfRepository::class)
* @Vich\Uploadable
*/
class MediaPdf extends MediaObject
{
/**
* @var string|null
* @ORM\JoinColumn(nullable=true, name="object_id")
*/
private ?string $object_id = null;
/**
* @var string|null
* @ApiProperty(iri="http://schema.org/contentUrl")
* @SerializedName("content_url")
* @Groups({
* "MediaObject:output",
* "MediaPdf:output",
* "media_object_read",
* })
*/
private $contentUrl;
/**
* @var File|null
* @Assert\NotNull(
* groups={
* "media_object_read",
* "MediaPdf:io",
* "MediaObject:output",
* })
* @Assert\File(
* maxSize = "8M",
* mimeTypes = {"application/pdf"},
* maxSizeMessage = "La taille du pdf maximale autorisée est de 8 MO.",
* mimeTypesMessage = "Seuls les fichiers au format .pdf sont autorisés."
* )
* @Vich\UploadableField(mapping="library_pdf", fileNameProperty="filePath")
* @Groups({
* "MediaPdf:output",
* })
*/
public $file;
/**
* @var string|null
*
* @ORM\Column(nullable=true)
* @SerializedName("file_path")
* @Groups({
* "MediaPdf:output",
* })
*/
public $filePath;
/**
* @return string|null
*/
public function getContentUrl(): ?string
{
return $this->contentUrl;
}
/**
* @param string|null $contentUrl
* @return MediaPdf
*/
public function setContentUrl(?string $contentUrl): MediaPdf
{
$this->contentUrl = $contentUrl;
return $this;
}
/**
* @return string|null
*/
public function getObjectId(): ?string
{
return $this->object_id;
}
/**
* @param string|null $object_id
* @return MediaPdf
*/
public function setObjectId(?string $object_id): MediaPdf
{
$this->contentUrl = $object_id;
return $this;
}
}