src/Entity/DocumentVersion.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity(
  8.  *     repositoryClass="App\Repository\DocumentVersionRepository"
  9.  * )
  10.  * @ORM\Table(
  11.  *     name="document_version",
  12.  *     options={"collate"="utf8_swedish_ci"}
  13.  * )
  14.  * @ORM\InheritanceType("SINGLE_TABLE")
  15.  * @ORM\DiscriminatorColumn(
  16.  *     name="entity",
  17.  *     type="string",
  18.  *     length=50
  19.  * )
  20.  * @ORM\DiscriminatorMap({
  21.  *     "offer"="DocumentVersionOffer",
  22.  *     "order_confirmation"="DocumentVersionOrderConfirmation",
  23.  *     "purchase_order"="DocumentVersionPurchaseOrder",
  24.  *     "invoice"="DocumentVersionInvoice",
  25.  *     "packing_list"="DocumentVersionPackingList"
  26.  * })
  27.  * @ORM\HasLifecycleCallbacks
  28.  */
  29. abstract class DocumentVersion implements EntityInterface
  30. {
  31.     /**
  32.      * @ORM\Id
  33.      * @ORM\Column(
  34.      *     type="integer"
  35.      * )
  36.      * @ORM\GeneratedValue(
  37.      *     strategy="AUTO"
  38.      * )
  39.      *
  40.      * @var int|null
  41.      */
  42.     protected ?int $id null;
  43.     /**
  44.      * @ORM\Column(
  45.      *     type="datetime"
  46.      * )
  47.      * @Assert\NotBlank
  48.      *
  49.      * @var DateTime
  50.      */
  51.     protected DateTime $created;
  52.     /**
  53.      * @ORM\Column(
  54.      *     type="blob"
  55.      * )
  56.      * @Assert\NotBlank
  57.      *
  58.      * @var resource
  59.      */
  60.     protected $file;
  61.     /**
  62.      * @param string $file
  63.      */
  64.     public function __construct(string $file)
  65.     {
  66.         $this->setFile($file);
  67.         $this->created = new DateTime();
  68.     }
  69.     /**
  70.      * @return DateTime
  71.      */
  72.     public function getCreated(): DateTime
  73.     {
  74.         return $this->created;
  75.     }
  76.     /**
  77.      * @return resource
  78.      */
  79.     public function getFile()
  80.     {
  81.         return $this->file;
  82.     }
  83.     /**
  84.      * @return string
  85.      */
  86.     abstract public function getFileName(): string;
  87.     /**
  88.      * @return int|null
  89.      */
  90.     public function getId(): ?int
  91.     {
  92.         return $this->id;
  93.     }
  94.     /**
  95.      * @ORM\PrePersist()
  96.      */
  97.     public function prePersist()
  98.     {
  99.         $this->created = new DateTime();
  100.     }
  101.     /**
  102.      * @param string $file
  103.      */
  104.     public function setFile(string $file)
  105.     {
  106.         $this->file $file;
  107.     }
  108. }