/** * @param SchemaContainer $schemaContainer */ public function guess(SchemaContainer $schemaContainer) { $fieldContainers = $schemaContainer->getTypes() + $schemaContainer->getInterfaces(); if (null !== ($query = $schemaContainer->getQuerySchema())) { $fieldContainers[] = $query; } foreach ($fieldContainers as $fieldContainer) { $containerContext = new ContainerContext($fieldContainer, $schemaContainer); $this->guessFields($containerContext); $this->guessTypeResolveConfig($containerContext); } }
/** * @param SchemaContainer $schemaContainer */ private function defineInteracesChildren(SchemaContainer $schemaContainer) { foreach ($schemaContainer->getTypes() as $type) { if (null === $type->getModel()) { continue; } foreach ($type->getInterfaces() as $interfaceName) { $interface = $schemaContainer->getInterface($interfaceName); $interface->setChildClass($type->getName(), $type->getModel()); } } }
/** * @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); } } }