FileWithMaxSize.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace Uploadable\Fixture\Entity;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. /**
  7. * @ORM\Entity
  8. * @Gedmo\Uploadable(allowOverwrite=true, pathMethod="getPath", callback="callbackMethod", maxSize="1")
  9. */
  10. class FileWithMaxSize
  11. {
  12. /**
  13. * @ORM\Column(name="id", type="integer")
  14. * @ORM\Id
  15. * @ORM\GeneratedValue(strategy="IDENTITY")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\Column(name="title", type="string", nullable=true)
  20. */
  21. private $title;
  22. /**
  23. * @ORM\Column(name="path", type="string")
  24. * @Gedmo\UploadableFilePath
  25. */
  26. private $filePath;
  27. /**
  28. * @ORM\Column(name="size", type="decimal")
  29. * @Gedmo\UploadableFileSize
  30. */
  31. private $fileSize;
  32. /**
  33. * @ORM\ManyToOne(targetEntity="Article", inversedBy="files")
  34. * @ORM\JoinColumn(name="article_id", referencedColumnName="id")
  35. */
  36. private $article;
  37. public $callbackWasCalled = false;
  38. public function getId()
  39. {
  40. return $this->id;
  41. }
  42. public function setTitle($title)
  43. {
  44. $this->title = $title;
  45. }
  46. public function getTitle()
  47. {
  48. return $this->title;
  49. }
  50. public function setFilePath($filePath)
  51. {
  52. $this->filePath = $filePath;
  53. }
  54. public function getFilePath()
  55. {
  56. return $this->filePath;
  57. }
  58. public function setArticle(Article $article)
  59. {
  60. $this->article = $article;
  61. }
  62. public function getArticle()
  63. {
  64. return $this->article;
  65. }
  66. public function setFileSize($size)
  67. {
  68. $this->fileSize = $size;
  69. }
  70. public function getFileSize()
  71. {
  72. return $this->fileSize;
  73. }
  74. public function callbackMethod()
  75. {
  76. $this->callbackWasCalled = true;
  77. }
  78. public function getPath()
  79. {
  80. return __DIR__.'/../../../../temp/uploadable';
  81. }
  82. }