UploadableBaseEventArgs.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace Gedmo\Uploadable\Event;
  3. use Doctrine\Common\EventArgs;
  4. use Doctrine\ORM\EntityManager;
  5. use Gedmo\Uploadable\FileInfo\FileInfoInterface;
  6. use Gedmo\Uploadable\UploadableListener;
  7. /**
  8. * Abstract Base Event to be extended by Uploadable events
  9. *
  10. * @author Gustavo Falco <comfortablynumb84@gmail.com>
  11. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. abstract class UploadableBaseEventArgs extends EventArgs
  15. {
  16. /**
  17. * The instance of the Uploadable listener that fired this event
  18. *
  19. * @var \Gedmo\Uploadable\UploadableListener
  20. */
  21. private $uploadableListener;
  22. /**
  23. * @var \Doctrine\ORM\EntityManager
  24. */
  25. private $em;
  26. /**
  27. * The Uploadable entity
  28. *
  29. * @var object $entity
  30. */
  31. private $entity;
  32. /**
  33. * The configuration of the Uploadable extension for this entity class
  34. *
  35. * @var array $extensionConfiguration
  36. */
  37. private $extensionConfiguration;
  38. /**
  39. * @var \Gedmo\Uploadable\FileInfo\FileInfoInterface
  40. */
  41. private $fileInfo;
  42. /**
  43. * @var string $action - Is the file being created, updated or removed?
  44. * This value can be: CREATE, UPDATE or DELETE.
  45. */
  46. private $action;
  47. /**
  48. * @param \Gedmo\Uploadable\UploadableListener $listener
  49. * @param \Doctrine\ORM\EntityManager $em
  50. * @param array $config
  51. * @param \Gedmo\Uploadable\FileInfo\FileInfoInterface $fileInfo
  52. * @param $entity
  53. * @param $action
  54. */
  55. public function __construct(UploadableListener $listener, EntityManager $em, array $config, FileInfoInterface $fileInfo, $entity, $action)
  56. {
  57. $this->uploadableListener = $listener;
  58. $this->em = $em;
  59. $this->config = $config;
  60. $this->fileInfo = $fileInfo;
  61. $this->entity = $entity;
  62. $this->action = $action;
  63. }
  64. /**
  65. * Retrieve the associated listener
  66. *
  67. * @return \Gedmo\Uploadable\UploadableListener
  68. */
  69. public function getListener()
  70. {
  71. return $this->uploadableListener;
  72. }
  73. /**
  74. * Retrieve associated EntityManager
  75. *
  76. * @return \Doctrine\ORM\EntityManager
  77. */
  78. public function getEntityManager()
  79. {
  80. return $this->em;
  81. }
  82. /**
  83. * Retrieve associated Entity
  84. *
  85. * @return object
  86. */
  87. public function getEntity()
  88. {
  89. return $this->entity;
  90. }
  91. /**
  92. * Retrieve associated Uploadable extension configuration
  93. *
  94. * @return array
  95. */
  96. public function getExtensionConfiguration()
  97. {
  98. return $this->extensionConfiguration;
  99. }
  100. /**
  101. * Retrieve the FileInfo associated with this entity.
  102. *
  103. * @return \Gedmo\Uploadable\FileInfo\FileInfoInterface
  104. */
  105. public function getFileInfo()
  106. {
  107. return $this->fileInfo;
  108. }
  109. /**
  110. * Retrieve the action being performed to the entity: CREATE, UPDATE or DELETE
  111. *
  112. * @return string
  113. */
  114. public function getAction()
  115. {
  116. return $this->action;
  117. }
  118. }