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