src/Entity/Contribution.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContributionRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Vich\UploaderBundle\Entity\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ContributionRepository::class)
  10.  * @Vich\Uploadable
  11.  */
  12. class Contribution
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="boolean")
  22.      */
  23.     private bool $published false;
  24.     /**
  25.      * @ORM\Column(type="boolean")
  26.      */
  27.     private bool $readed false;
  28.     /**
  29.      * @Assert\NotBlank
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private string $name;
  33.     /**
  34.      * @Assert\NotBlank
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private string $type;
  38.     /**
  39.      * @Assert\NotBlank
  40.      * @ORM\Column(type="text")
  41.      */
  42.     private string $content;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      * @var string
  46.      */
  47.     private $pdf;
  48.     /**
  49.      * @Vich\UploadableField(mapping="contribution_pdf", fileNameProperty="pdf")
  50.      * @var File
  51.      */
  52.     private $pdfFile;
  53.     /**
  54.      * @ORM\Column(type="datetime", nullable=true)
  55.      */
  56.     private ?\Datetime $createdAt;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity=User::class)
  59.      * @ORM\JoinColumn(nullable=true)
  60.      */
  61.     private ?User $validatedBy;
  62.     public function __construct()
  63.     {
  64.         $this->createdAt = new \DateTime();
  65.         $this->updatedAt = new \DateTime();
  66.     }
  67.     /**
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      */
  70.     private ?\Datetime $updatedAt;
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getName(): ?string
  76.     {
  77.         return $this->name;
  78.     }
  79.     public function setName(string $name): self
  80.     {
  81.         $this->name $name;
  82.         return $this;
  83.     }
  84.     public function getContent(): ?string
  85.     {
  86.         return $this->content;
  87.     }
  88.     public function setContent(string $content): self
  89.     {
  90.         $this->content $content;
  91.         return $this;
  92.     }
  93.     public function getCreatedAt(): ?\DateTimeInterface
  94.     {
  95.         return $this->createdAt;
  96.     }
  97.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  98.     {
  99.         $this->createdAt $createdAt;
  100.         return $this;
  101.     }
  102.     public function getUpdatedAt(): ?\DateTime
  103.     {
  104.         return $this->updatedAt;
  105.     }
  106.     public function setUpdatedAt(?\DateTime $updatedAt): void
  107.     {
  108.         $this->updatedAt $updatedAt;
  109.     }
  110.     public function setPdfFile($pdf null)
  111.     {
  112.         $this->pdfFile $pdf;
  113.         // VERY IMPORTANT:
  114.         // It is required that at least one field changes if you are using Doctrine,
  115.         // otherwise the event listeners won't be called and the file is lost
  116.         if ($pdf) {
  117.             // if 'updatedAt' is not defined in your entity, use another property
  118.             $this->updatedAt = new \DateTime('now');
  119.         }
  120.     }
  121.     public function getPdfFile()
  122.     {
  123.         return $this->pdfFile;
  124.     }
  125.     public function setPdf($pdf)
  126.     {
  127.         // $pdf = str_replace(' ', '_', $pdf);
  128.         $this->pdf $pdf;
  129.     }
  130.     public function getPdf()
  131.     {
  132.         return $this->pdf;
  133.     }
  134.     public function getType(): string
  135.     {
  136.         return $this->type;
  137.     }
  138.     public function setType(string $type): void
  139.     {
  140.         $this->type $type;
  141.     }
  142.     public function isPublished(): bool
  143.     {
  144.         return $this->published;
  145.     }
  146.     public function setPublished(bool $published): void
  147.     {
  148.         $this->published $published;
  149.     }
  150.     public function isReaded(): bool
  151.     {
  152.         return $this->readed;
  153.     }
  154.     public function setReaded(bool $readed): void
  155.     {
  156.         $this->readed $readed;
  157.     }
  158.     public function __toString()
  159.     {
  160.         return sprintf('#%s - %s'$this->id$this->name);
  161.     }
  162.     public function getValidatedBy(): ?User
  163.     {
  164.         return $this->validatedBy;
  165.     }
  166.     public function setValidatedBy(?User $validatedBy): void
  167.     {
  168.         $this->validatedBy $validatedBy;
  169.     }
  170. }