Guest User

Untitled

a guest
Oct 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. vich_uploader:
  2. db_driver: orm
  3. mappings:
  4. image_uploads:
  5. uri_prefix: '%path.image_uploads%'
  6. upload_destination: '%kernel.project_dir%/public%path.image_uploads%'
  7.  
  8. parameters:
  9. path.image_uploads: '/assets/images/uploads'
  10.  
  11. ContactPage:
  12. class: AppEntityContactPage
  13. label: 'Contact'
  14. list: //image not shown
  15. fields:
  16. - 'title'
  17. - 'content'
  18. - { property: 'image', type: 'image', basePath: '%path.image_uploads%' } //I also tried with the public prefix
  19. form: //works as intended
  20. title: '%%entity_label%%'
  21. fields:
  22. - 'title'
  23. - { property: 'content', type: 'FOSCKEditorBundleFormTypeCKEditorType' }
  24. - { property: 'imageFile', type: 'vich_image', basePath: '%path.image_uploads%' }
  25. - { property: 'imageAlt', label: 'Alt tag' }
  26. show: //image not shown
  27. title: '%%entity_label%%'
  28. fields:
  29. - 'title'
  30. - 'content'
  31. - { property: 'image', type: 'image' }
  32. - { property: 'imageAlt', label: 'Alt tag' }
  33.  
  34. use VichUploaderBundleMappingAnnotation as Vich;
  35. use SymfonyComponentHttpFoundationFileFile;
  36.  
  37.  
  38. /**
  39. * @ORMEntity
  40. * @VichUploadable
  41. */
  42. class ContactPage
  43. {
  44. /**
  45. * @ORMColumn(type="string", length=255, nullable=true)
  46. * @var string
  47. */
  48. private $image;
  49.  
  50. /**
  51. * @VichUploadableField(mapping="image_uploads", fileNameProperty="image")
  52. * @var File
  53. */
  54. private $imageFile;
  55.  
  56. /**
  57. * @return string|null
  58. */
  59. public function getImage(): ?string
  60. {
  61. return $this->image;
  62. }
  63.  
  64. /**
  65. * @param string|null $image
  66. * @return ContactPage
  67. */
  68. public function setImage(string $image): self
  69. {
  70. $this->image = $image;
  71.  
  72. return $this;
  73. }
  74.  
  75. /**
  76. * @return File|null
  77. */
  78. public function getImageFile(): ?File
  79. {
  80. return $this->imageFile;
  81. }
  82.  
  83. /**
  84. * @param File $imageFile
  85. */
  86. public function setImageFile(File $imageFile = null): void
  87. {
  88. $this->imageFile = $imageFile;
  89.  
  90. if ($imageFile) {
  91. $this->updatedAt = new DateTime('now');
  92. }
  93. }
  94. }
Add Comment
Please, Sign In to add comment