Skip to content

Commit

Permalink
Merge pull request #1628 from alcaeus/no-proxy-embedded-documents
Browse files Browse the repository at this point in the history
Don't generate proxy classes for embedded documents
  • Loading branch information
alcaeus authored Aug 15, 2017
2 parents 7c1a6b3 + 7e96bba commit 9d66593
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,11 +121,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);
}
}

0 comments on commit 9d66593

Please # to comment.