UploadableBaseEventArgs.php 3.2KB

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