<?php
namespace App\Entity;
use App\Repository\ContributionRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Entity\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=ContributionRepository::class)
* @Vich\Uploadable
*/
class Contribution
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="boolean")
*/
private bool $published = false;
/**
* @ORM\Column(type="boolean")
*/
private bool $readed = false;
/**
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
*/
private string $name;
/**
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
*/
private string $type;
/**
* @Assert\NotBlank
* @ORM\Column(type="text")
*/
private string $content;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string
*/
private $pdf;
/**
* @Vich\UploadableField(mapping="contribution_pdf", fileNameProperty="pdf")
* @var File
*/
private $pdfFile;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\Datetime $createdAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?User $validatedBy;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
}
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\Datetime $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTime $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
public function setPdfFile($pdf = null)
{
$this->pdfFile = $pdf;
// VERY IMPORTANT:
// 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
if ($pdf) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getPdfFile()
{
return $this->pdfFile;
}
public function setPdf($pdf)
{
// $pdf = str_replace(' ', '_', $pdf);
$this->pdf = $pdf;
}
public function getPdf()
{
return $this->pdf;
}
public function getType(): string
{
return $this->type;
}
public function setType(string $type): void
{
$this->type = $type;
}
public function isPublished(): bool
{
return $this->published;
}
public function setPublished(bool $published): void
{
$this->published = $published;
}
public function isReaded(): bool
{
return $this->readed;
}
public function setReaded(bool $readed): void
{
$this->readed = $readed;
}
public function __toString()
{
return sprintf('#%s - %s', $this->id, $this->name);
}
public function getValidatedBy(): ?User
{
return $this->validatedBy;
}
public function setValidatedBy(?User $validatedBy): void
{
$this->validatedBy = $validatedBy;
}
}