OnClearEventArgs.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Doctrine\Persistence\Event;
  3. use Doctrine\Common\EventArgs;
  4. use Doctrine\Persistence\ObjectManager;
  5. /**
  6. * Provides event arguments for the onClear event.
  7. */
  8. class OnClearEventArgs extends EventArgs
  9. {
  10. /** @var ObjectManager */
  11. private $objectManager;
  12. /** @var string|null */
  13. private $entityClass;
  14. /**
  15. * @param ObjectManager $objectManager The object manager.
  16. * @param string|null $entityClass The optional entity class.
  17. */
  18. public function __construct($objectManager, $entityClass = null)
  19. {
  20. $this->objectManager = $objectManager;
  21. $this->entityClass = $entityClass;
  22. }
  23. /**
  24. * Retrieves the associated ObjectManager.
  25. *
  26. * @return ObjectManager
  27. */
  28. public function getObjectManager()
  29. {
  30. return $this->objectManager;
  31. }
  32. /**
  33. * Returns the name of the entity class that is cleared, or null if all are cleared.
  34. *
  35. * @return string|null
  36. */
  37. public function getEntityClass()
  38. {
  39. return $this->entityClass;
  40. }
  41. /**
  42. * Returns whether this event clears all entities.
  43. *
  44. * @return bool
  45. */
  46. public function clearsAllEntities()
  47. {
  48. return $this->entityClass === null;
  49. }
  50. }