DDC-860 - Allow access to EntityManager in loadClassMetadata event
This commit is contained in:
parent
634aa0b291
commit
6a904a2d67
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user