Skip to content

Commit

Permalink
Detect associations inside embeddables
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszsip committed Oct 14, 2020
1 parent f1365b7 commit 30aa5be
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 113 deletions.
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Tools/SchemaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\DBAL\Types\Type;
use function count;

/**
* Performs strict validation of the mapping schema
Expand Down Expand Up @@ -96,6 +97,12 @@ public function validateClass(ClassMetadataInfo $class)
}
}

if ($class->isEmbeddedClass && count($class->associationMappings) > 0) {
$ce[] = "Embeddable '" . $class->name . "' does not support associations";

return $ce;
}

foreach ($class->associationMappings as $fieldName => $assoc) {
if (!class_exists($assoc['targetEntity']) || $cmf->isTransient($assoc['targetEntity'])) {
$ce[] = "The target entity '" . $assoc['targetEntity'] . "' specified on " . $class->name . '#' . $fieldName . ' is unknown or not an entity.';
Expand Down
Loading

0 comments on commit 30aa5be

Please sign in to comment.