File.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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")
  9. */
  10. class File
  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\ManyToOne(targetEntity="Article", inversedBy="files")
  29. * @ORM\JoinColumn(name="article_id", referencedColumnName="id")
  30. */
  31. private $article;
  32. public $callbackWasCalled = false;
  33. public function getId()
  34. {
  35. return $this->id;
  36. }
  37. public function setTitle($title)
  38. {
  39. $this->title = $title;
  40. }
  41. public function getTitle()
  42. {
  43. return $this->title;
  44. }
  45. public function setFilePath($filePath)
  46. {
  47. $this->filePath = $filePath;
  48. }
  49. public function getFilePath()
  50. {
  51. return $this->filePath;
  52. }
  53. public function setArticle(Article $article)
  54. {
  55. $this->article = $article;
  56. }
  57. public function getArticle()
  58. {
  59. return $this->article;
  60. }
  61. public function callbackMethod()
  62. {
  63. $this->callbackWasCalled = true;
  64. }
  65. public function getPath()
  66. {
  67. return __DIR__.'/../../../../temp/uploadable';
  68. }
  69. }