1
0
mirror of synced 2025-01-18 06:21:40 +03:00

DDC-1278 - Clean up event handling of new clear functionality.

This commit is contained in:
Benjamin Eberlei 2011-10-16 22:45:06 +02:00
parent 22a04fd6de
commit 939fbf9c24
2 changed files with 28 additions and 2 deletions

View File

@ -36,12 +36,18 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
*/
private $em;
/**
* @var string
*/
private $entityClass;
/**
* @param \Doctrine\ORM\EntityManager $em
*/
public function __construct($em)
public function __construct($em, $entityClass = null)
{
$this->em = $em;
$this->entityClass = $entityClass;
}
/**
@ -51,4 +57,24 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
{
return $this->em;
}
/**
* Name of the entity class that is cleared, or empty if all are cleared.
*
* @return string
*/
public function getEntityClass()
{
return $this->entityClass;
}
/**
* Check if event clears all entities.
*
* @return bool
*/
public function clearsAllEntities()
{
return $this->entityClass === null;
}
}

View File

@ -1879,7 +1879,7 @@ class UnitOfWork implements PropertyChangedListener
}
if ($this->evm->hasListeners(Events::onClear)) {
$this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->em));
$this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->em, $entityName));
}
}