1
0
mirror of synced 2025-01-19 06:51:40 +03:00

Enabling fallback logic in metadata loading

This commit is contained in:
Marco Pivetta 2014-11-11 15:51:52 +01:00
parent d91b0b4938
commit e4cbdb57ad

View File

@ -22,6 +22,10 @@ namespace Doctrine\ORM\Mapping;
use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory; use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface; use Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface;
use Doctrine\Common\Persistence\Mapping\ReflectionService; use Doctrine\Common\Persistence\Mapping\ReflectionService;
use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs;
use ReflectionException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Platforms; use Doctrine\DBAL\Platforms;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
@ -78,7 +82,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
} }
/** /**
* {@inheritDoc}. * {@inheritDoc}
*/ */
protected function initialize() protected function initialize()
{ {
@ -88,6 +92,23 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
$this->initialized = true; $this->initialized = true;
} }
/**
* {@inheritDoc}
*/
protected function onNotFoundMetadata($className)
{
if (! $this->evm->hasListeners(Events::onClassMetadataNotFound)) {
return;
}
$eventArgs = new OnClassMetadataNotFoundEventArgs($className, $this->em);
$this->evm->dispatchEvent(Events::onClassMetadataNotFound, $eventArgs);
// @todo to be discussed: event is used as a mutable data vector here, which may be undesired.
return $eventArgs->getFoundMetadata();
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */