/** * @param ClassMetadataInfo $metadata * @param Field $field * @param SchemaContainer $schemaContainer * @return TypeGuess * @throws MappingException */ private function guessAssociation(ClassMetadataInfo $metadata, Field $field, SchemaContainer $schemaContainer) { $property = $field->getProperty() ?: $field->getName(); $multiple = $metadata->isCollectionValuedAssociation($property); $mapping = $metadata->getAssociationMapping($property); foreach ($schemaContainer->getTypes() as $type) { $containerContext = new ContainerContext($type, $schemaContainer); if (!$this->isFieldContainerSupported($containerContext)) { continue; } if ($type->getModel() === $mapping['targetEntity']) { $typeName = $type->getName(); if ($multiple) { $typeName = sprintf('[%s]', $typeName); } return new TypeGuess($typeName, Guess::HIGH_CONFIDENCE); } } }