Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

AbstractDocumentEntity.php 2.8KB

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