vendor/fri0z/mldev-catalog-bundle/src/Entity/ProductDocument.php line 16

Open in your IDE?
  1. <?php
  2. namespace MLDev\CatalogBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use MLDev\BaseBundle\Entity\Traits\Timestampable;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use MLDev\CatalogBundle\Repository\ProductDocumentRepository;
  7. use function file_exists;
  8. /**
  9.  * @ORM\Table(name="MLDev_Product_Document")
  10.  * @ORM\Entity(repositoryClass=ProductDocumentRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class ProductDocument
  14. {
  15.     use Timestampable;
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", name="title", length=50)
  24.      */
  25.     protected $title;
  26.     /**
  27.      * @ORM\Column(type="string", name="name", length=50)
  28.      */
  29.     protected $name;
  30.     /**
  31.      * @ORM\Column(type="string", name="path", length=255)
  32.      */
  33.     protected $path;
  34.     /**
  35.      * @ORM\Column(type="string", name="uri", length=255)
  36.      */
  37.     protected $uri;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity="MLDev\CatalogBundle\Entity\Product", inversedBy="documents", cascade={"persist"})
  40.      * @ORM\JoinColumn(name="product_id", referencedColumnName="id")
  41.      */
  42.     protected $product;
  43.     /**
  44.      * @var File|null
  45.      */
  46.     protected $file;
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getTitle(): ?string
  52.     {
  53.         return $this->title;
  54.     }
  55.     public function setTitle($title): void
  56.     {
  57.         $this->title $title;
  58.     }
  59.     public function getName(): ?string
  60.     {
  61.         return $this->name;
  62.     }
  63.     public function setName(?string $name): void
  64.     {
  65.         $this->name $name;
  66.     }
  67.     public function getPath(): ?string
  68.     {
  69.         return $this->path;
  70.     }
  71.     public function setPath(?string $path): void
  72.     {
  73.         $this->path $path;
  74.     }
  75.     public function getProduct(): ?Product
  76.     {
  77.         return $this->product;
  78.     }
  79.     public function setProduct(?Product $product): void
  80.     {
  81.         $this->product $product;
  82.     }
  83.     public function getFile(): ?File
  84.     {
  85.         if ($this->file instanceof File) {
  86.             return $this->file;
  87.         }
  88.         if (file_exists($this->path)) {
  89.             return new File($this->path);
  90.         }
  91.         return null;
  92.     }
  93.     public function setFile(File $file): void
  94.     {
  95.         $this->file $file;
  96.     }
  97.     public function getUri(): ?string
  98.     {
  99.         return $this->uri;
  100.     }
  101.     public function setUri(?string $uri)
  102.     {
  103.         $this->uri $uri;
  104.     }
  105. }