From e4cbdb57adb80d1f00d3a2fcaaa05f8e3b1628b8 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 11 Nov 2014 15:51:52 +0100 Subject: [PATCH] Enabling fallback logic in metadata loading --- .../ORM/Mapping/ClassMetadataFactory.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 79e2fc8de..498ff5400 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -22,6 +22,10 @@ namespace Doctrine\ORM\Mapping; use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory; use Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface; 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\ORM\EntityManagerInterface; use Doctrine\ORM\Event\LoadClassMetadataEventArgs; @@ -78,7 +82,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory } /** - * {@inheritDoc}. + * {@inheritDoc} */ protected function initialize() { @@ -88,6 +92,23 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $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} */