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.

169 lines
3.8KB

  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. /**
  41. * @ORM\Column(type="text", nullable=true)
  42. */
  43. protected $metaDescription;
  44. /**
  45. * @var array
  46. * @ORM\Column(name="old_url", type="array", nullable=true)
  47. */
  48. private $oldUrl;
  49. public function setImageFile(File $image = null)
  50. {
  51. $this->imageFile = $image;
  52. // VERY IMPORTANT:
  53. // It is required that at least one field changes if you are using Doctrine,
  54. // otherwise the event listeners won't be called and the file is lost
  55. if ($image) {
  56. // if 'updatedAt' is not defined in your entity, use another property
  57. $this->updatedAt = new \DateTime('now');
  58. }
  59. }
  60. public function getImageFile()
  61. {
  62. return $this->imageFile;
  63. }
  64. public function getTitle(): ?string
  65. {
  66. return $this->title;
  67. }
  68. public function setTitle(string $title): self
  69. {
  70. $this->title = $title;
  71. return $this;
  72. }
  73. public function getDescription(): ?string
  74. {
  75. return $this->description;
  76. }
  77. public function setDescription(?string $description): self
  78. {
  79. $this->description = $description;
  80. return $this;
  81. }
  82. /**
  83. * Set oldUrl
  84. *
  85. * @param array $oldUrl
  86. *
  87. * @return AbstractEntity
  88. */
  89. public function setOldUrl($oldUrl)
  90. {
  91. $this->oldUrl = $oldUrl;
  92. return $this;
  93. }
  94. /**
  95. * Get oldUrl
  96. *
  97. * @return array
  98. */
  99. public function getOldUrl()
  100. {
  101. return $this->oldUrl;
  102. }
  103. public function getMetaDescription(): ?string
  104. {
  105. return $this->metaDescription;
  106. }
  107. public function setMetaDescription(?string $metaDescription): self
  108. {
  109. $this->metaDescription = $metaDescription;
  110. return $this;
  111. }
  112. public function getImage(): ?string
  113. {
  114. return $this->image;
  115. }
  116. public function setImage(?string $image): self
  117. {
  118. $this->image = $image;
  119. return $this;
  120. }
  121. public function getDevAlias(): ?string
  122. {
  123. return $this->devAlias;
  124. }
  125. public function setDevAlias(?string $devAlias): self
  126. {
  127. $this->devAlias = $devAlias;
  128. return $this;
  129. }
  130. }