<?phpnamespace App\Entity\Articles;use Doctrine\DBAL\Types\Types;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Validator\Constraints as Assert;use Doctrine\ORM\Mapping as ORM;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Symfony\Component\HttpFoundation\File\File;use App\Repository\Articles\ArticlesAuthorsRepository;use Symfony\Component\HttpFoundation\File\UploadedFile;use Vich\UploaderBundle\Entity\File as EmbeddedFile;/** * Articles * * @ORM\Table("articles_articles_authors") * @ORM\Entity(repositoryClass=ArticlesAuthorsRepository::class) * @ORM\HasLifecycleCallbacks() * @Vich\Uploadable */class ArticlesAuthors { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * [Groups(['list', 'item'])] */ protected $id; /** * @var string * * @ORM\Column(name="created_at", type="datetime", nullable=true, options={"comment":"Date de création"}) */ private $createdAt; /** * @var string * * @ORM\Column(name="updated_at", type="datetime", nullable=true, options={"comment":"Date de mise à jour"}) */ private $updatedAt; /** * @var string * * @ORM\Column(name="title", type="string", length=500, nullable=true) * [Groups(['list', 'item'])] */ private $title; /** * @var string * * @ORM\Column(name="description", type="text", nullable=true) * [Groups(['list', 'item'])] */ private $description; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. * * @Vich\UploadableField(mapping="authors_files", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName", dimensions="image.dimensions") * @Assert\File( * maxSize = "8M", * mimeTypes={"image/jpeg", "image/png", "image/webp"}, * mimeTypesMessage = "Please upload a valid PDF or image" * ) * @var File|null */ private $imageFile; /** * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File") * * @var EmbeddedFile */ private $image; /** * @var string * * @ORM\Column(name="image_alt", type="string", length=500, nullable=true) */ private $imageAlt; /** * @var string * * @ORM\Column(name="image_title", type="string", length=500, nullable=true) */ private $imageTitle; /** * @var string * * @ORM\Column(name="author", type="string", length=155, nullable=true) */ private $author; /** * @var string * * @ORM\Column(name="locale", type="string", length=155, nullable=true) */ private $locale; /** * @var string * * @ORM\Column(name="linkedin_url", type="string", length=155, nullable=true) */ private $linkedinUrl; public function __construct() { $this->image = new \Vich\UploaderBundle\Entity\File(); } /** * @ORM\PrePersist */ public function setCreatedAtValue(): void { $this->setCreatedAt(new \DateTime("now")); $this->setUpdatedAt(new \DateTime("now")); } /** * @ORM\PreUpdate */ public function setUpdatedAtValue(): void { $this->setUpdatedAt(new \DateTime("now")); } public function __toString() { return $this->title; } /** * If manually uploading a file (i.e. not using Symfony Form) ensure an instance * of 'UploadedFile' is injected into this setter to trigger the update. If this * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter * must be able to accept an instance of 'File' as the bundle will inject one here * during Doctrine hydration. * * @param File|UploadedFile|null $imageFile */ public function setImageFile(?File $imageFile = null) { $this->imageFile = $imageFile; if (null !== $imageFile) { // It is required that at least one field changes if you are using doctrine // otherwise the event listeners won't be called and the file is lost $this->setUpdatedAt(new \DateTime("now")); } } public function getImageFile(): ?File { return $this->imageFile; } public function setImage(EmbeddedFile $image): void { $this->image = $image; } public function getImage(): ?EmbeddedFile { return $this->image; } public function getId(): ?int { return $this->id; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(?\DateTimeInterface $createdAt): static { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): static { $this->updatedAt = $updatedAt; return $this; } public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): static { $this->title = $title; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getImageAlt(): ?string { return $this->imageAlt; } public function setImageAlt(?string $imageAlt): static { $this->imageAlt = $imageAlt; return $this; } public function getImageTitle(): ?string { return $this->imageTitle; } public function setImageTitle(?string $imageTitle): static { $this->imageTitle = $imageTitle; return $this; } public function getAuthor(): ?string { return $this->author; } public function setAuthor(?string $author): static { $this->author = $author; return $this; } public function getLocale(): ?string { return $this->locale; } public function setLocale(?string $locale): static { $this->locale = $locale; return $this; } public function getLinkedinUrl(): ?string { return $this->linkedinUrl; } public function setLinkedinUrl(?string $linkedinUrl): static { $this->linkedinUrl = $linkedinUrl; return $this; }}