示例#1
0
 /**
  * @param Field[]                             $fields
  * @param AbstractType|FieldContainer[]|Field $parent
  */
 private function prepareFields(array $fields, AbstractType $parent)
 {
     foreach ($fields as $field) {
         if (null !== $field->getArguments()) {
             $this->prepareFields($field->getArguments(), $field);
         }
         $this->prepareResolver($field);
         $typeName = $field->getType();
         if (empty($typeName)) {
             throw new \InvalidArgumentException(sprintf('Missing type for field "%s" in "%s"', $field->getName(), $parent->getName()));
         }
         $field->setResolvedType(function () use($typeName) {
             return $this->typeResolver->resolveType($typeName);
         });
     }
 }
示例#2
0
 /**
  * @param Field[] $fields
  */
 private function prepareFields(array $fields)
 {
     foreach ($fields as $field) {
         if (null !== $field->getArguments()) {
             $this->prepareFields($field->getArguments());
         }
         $resolveConfig = $field->getResolveConfig();
         if (isset($resolveConfig['handler'])) {
             $handler = $resolveConfig['handler'];
             $resolver = $this->resolveFactories[$handler]->getFunction($resolveConfig, $field);
             $field->setResolve($resolver);
         }
         $typeName = $field->getType();
         $field->setResolvedType(function () use($typeName) {
             return $this->typeResolver->resolveType($typeName);
         });
     }
 }