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

DDC-860 - Allow access to EntityManager in loadClassMetadata event

This commit is contained in:
Benjamin Eberlei 2010-11-05 22:13:19 +01:00
parent 634aa0b291
commit 6a904a2d67
2 changed files with 32 additions and 5 deletions

View File

@ -4,6 +4,9 @@ namespace Doctrine\ORM\Event;
use Doctrine\Common\EventArgs; use Doctrine\Common\EventArgs;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\EntityManager;
/** /**
* Class that holds event arguments for a loadMetadata event. * Class that holds event arguments for a loadMetadata event.
* *
@ -12,16 +15,40 @@ use Doctrine\Common\EventArgs;
*/ */
class LoadClassMetadataEventArgs extends EventArgs class LoadClassMetadataEventArgs extends EventArgs
{ {
private $_classMetadata; /**
* @var ClassMetadata
*/
private $classMetadata;
public function __construct(\Doctrine\ORM\Mapping\ClassMetadata $classMetadata) /**
* @var EntityManager
*/
private $em;
/**
* @param ClassMetadata $classMetadata
* @param EntityManager $em
*/
public function __construct(ClassMetadata $classMetadata, EntityManager $em)
{ {
$this->_classMetadata = $classMetadata; $this->classMetadata = $classMetadata;
$this->em = $em;
} }
/**
* @return ClassMetadata
*/
public function getClassMetadata() public function getClassMetadata()
{ {
return $this->_classMetadata; return $this->classMetadata;
}
/**
* @return EntityManager
*/
public function getEntityManager()
{
return $this->em;
} }
} }

View File

@ -309,7 +309,7 @@ class ClassMetadataFactory
$class->setParentClasses($visited); $class->setParentClasses($visited);
if ($this->evm->hasListeners(Events::loadClassMetadata)) { if ($this->evm->hasListeners(Events::loadClassMetadata)) {
$eventArgs = new \Doctrine\ORM\Event\LoadClassMetadataEventArgs($class); $eventArgs = new \Doctrine\ORM\Event\LoadClassMetadataEventArgs($class, $this->em);
$this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs); $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
} }