126 líneas
2.9KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. use Lc\ShopBundle\Context\SeoInterface;
  6. use Lc\ShopBundle\Context\SluggableInterface;
  7. use Lc\ShopBundle\Context\SortableInterface;
  8. use Lc\ShopBundle\Context\StatusInterface;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12. * @ORM\MappedSuperclass
  13. * @Vich\Uploadable
  14. */
  15. abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface, SeoInterface
  16. {
  17. use SortableTrait;
  18. use StatusTrait;
  19. use SluggableTrait;
  20. use SeoTrait;
  21. /**
  22. * @ORM\Column(type="string", length=255)
  23. */
  24. protected $title;
  25. /**
  26. * @ORM\Column(type="text", nullable=true)
  27. */
  28. protected $description;
  29. /**
  30. * @ORM\Column(type="string", length=255, nullable=true)
  31. */
  32. protected $image;
  33. /**
  34. * @Vich\UploadableField(mapping="images", fileNameProperty="image")
  35. * @var File
  36. */
  37. protected $imageFile;
  38. /**
  39. * @ORM\Column(type="string", length=255, nullable=true)
  40. */
  41. protected $devAlias;
  42. public function setImageFile(File $image = null)
  43. {
  44. $this->imageFile = $image;
  45. // VERY IMPORTANT:
  46. // It is required that at least one field changes if you are using Doctrine,
  47. // otherwise the event listeners won't be called and the file is lost
  48. if ($image) {
  49. // if 'updatedAt' is not defined in your entity, use another property
  50. $this->updatedAt = new \DateTime('now');
  51. }
  52. }
  53. public function getImageFile()
  54. {
  55. return $this->imageFile;
  56. }
  57. public function getTitle(): ?string
  58. {
  59. return $this->title;
  60. }
  61. public function setTitle(string $title): self
  62. {
  63. $this->title = $title;
  64. return $this;
  65. }
  66. public function getDescription(): ?string
  67. {
  68. return $this->description;
  69. }
  70. public function setDescription(?string $description): self
  71. {
  72. $this->description = $description;
  73. return $this;
  74. }
  75. public function getImage(): ?string
  76. {
  77. return $this->image;
  78. }
  79. public function setImage(?string $image): self
  80. {
  81. $this->image = $image;
  82. return $this;
  83. }
  84. public function getDevAlias(): ?string
  85. {
  86. return $this->devAlias;
  87. }
  88. public function setDevAlias(?string $devAlias): self
  89. {
  90. $this->devAlias = $devAlias;
  91. return $this;
  92. }
  93. }