<?phpnamespace App\Entity;use DateTime;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;/** * @ORM\Entity( * repositoryClass="App\Repository\DocumentVersionRepository" * ) * @ORM\Table( * name="document_version", * options={"collate"="utf8_swedish_ci"} * ) * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn( * name="entity", * type="string", * length=50 * ) * @ORM\DiscriminatorMap({ * "offer"="DocumentVersionOffer", * "order_confirmation"="DocumentVersionOrderConfirmation", * "purchase_order"="DocumentVersionPurchaseOrder", * "invoice"="DocumentVersionInvoice", * "packing_list"="DocumentVersionPackingList" * }) * @ORM\HasLifecycleCallbacks */abstract class DocumentVersion implements EntityInterface{ /** * @ORM\Id * @ORM\Column( * type="integer" * ) * @ORM\GeneratedValue( * strategy="AUTO" * ) * * @var int|null */ protected ?int $id = null; /** * @ORM\Column( * type="datetime" * ) * @Assert\NotBlank * * @var DateTime */ protected DateTime $created; /** * @ORM\Column( * type="blob" * ) * @Assert\NotBlank * * @var resource */ protected $file; /** * @param string $file */ public function __construct(string $file) { $this->setFile($file); $this->created = new DateTime(); } /** * @return DateTime */ public function getCreated(): DateTime { return $this->created; } /** * @return resource */ public function getFile() { return $this->file; } /** * @return string */ abstract public function getFileName(): string; /** * @return int|null */ public function getId(): ?int { return $this->id; } /** * @ORM\PrePersist() */ public function prePersist() { $this->created = new DateTime(); } /** * @param string $file */ public function setFile(string $file) { $this->file = $file; }}