From 7e96bba1b38dcd00fdb8cae0b55921ee2dbc93b1 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Fri, 11 Aug 2017 15:10:40 +0200 Subject: [PATCH] Only generate proxies for documents --- .../Console/Command/GenerateProxiesCommand.php | 5 ++++- .../Tools/Console/Command/Schema/CreateCommand.php | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php index f5e83075f4..abbdb9bb8b 100644 --- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php +++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php @@ -19,6 +19,7 @@ namespace Doctrine\ODM\MongoDB\Tools\Console\Command; +use Doctrine\ODM\MongoDB\Mapping\ClassMetadata; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console; @@ -62,7 +63,9 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O { $dm = $this->getHelper('documentManager')->getDocumentManager(); - $metadatas = $dm->getMetadataFactory()->getAllMetadata(); + $metadatas = array_filter($dm->getMetadataFactory()->getAllMetadata(), function (ClassMetadata $classMetadata) { + return !$classMetadata->isEmbeddedDocument && !$classMetadata->isMappedSuperclass; + }); $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); // Process destination directory diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php index fa458496c0..a56ebae179 100644 --- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php +++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php @@ -19,6 +19,7 @@ namespace Doctrine\ODM\MongoDB\Tools\Console\Command\Schema; +use Doctrine\ODM\MongoDB\Mapping\ClassMetadata; use Doctrine\ODM\MongoDB\SchemaManager; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -116,11 +117,19 @@ protected function processIndex(SchemaManager $sm) protected function processDocumentProxy(SchemaManager $sm, $document) { - $this->getDocumentManager()->getProxyFactory()->generateProxyClasses(array($this->getMetadataFactory()->getMetadataFor($document))); + $classMetadata = $this->getMetadataFactory()->getMetadataFor($document); + + if (!$classMetadata->isEmbeddedDocument && !$classMetadata->isMappedSuperclass) { + $this->getDocumentManager()->getProxyFactory()->generateProxyClasses(array($classMetadata)); + } } protected function processProxy(SchemaManager $sm) { - $this->getDocumentManager()->getProxyFactory()->generateProxyClasses($this->getMetadataFactory()->getAllMetadata()); + $classes = array_filter($this->getMetadataFactory()->getAllMetadata(), function (ClassMetadata $classMetadata) { + return !$classMetadata->isEmbeddedDocument && !$classMetadata->isMappedSuperclass; + }); + + $this->getDocumentManager()->getProxyFactory()->generateProxyClasses($classes); } }