<?php
namespace App\Entity;
use App\Repository\DocumentRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=DocumentRepository::class)
* @ORM\HasLifecycleCallbacks()
* @Vich\Uploadable
*/
class Document
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $document;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string|null
*/
private $name;
/**
* @Vich\UploadableField(mapping="visio_documents", fileNameProperty="document", originalName="name")
* @Assert\File(
* mimeTypes={"image/jpeg", "image/gif", "image/png", "application/pdf"},
* maxSize="700Ki",
* mimeTypesMessage="document_upload_type"
* )
* @var File
*/
protected $documentFile;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=VisioEvent::class, inversedBy="documents")
*/
private $visioEvent;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
*/
private $owner;
public function __construct()
{
$this->createdAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getDocument(): ?string
{
return $this->document;
}
public function setDocument(?string $document): self
{
$this->document = $document;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getVisioEvent(): ?VisioEvent
{
return $this->visioEvent;
}
public function setVisioEvent(?VisioEvent $visioEvent): self
{
$this->visioEvent = $visioEvent;
return $this;
}
/**
* @param File|null $documentFile
* @return Document
*/
public function setDocumentFile(?File $documentFile = null): self
{
$this->documentFile = $documentFile;
if ($documentFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
return $this;
}
/**
* @return File|null
*/
public function getDocumentFile(): ?File
{
return $this->documentFile;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @param string|null $name
* @return Document
*/
public function setName(?string $name): Document
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
}