Create an InputObjectType from a Doctrine entity

@param string $className class name of Doctrine entity
@param string $typeName GraphQL type name

@return InputObjectType
162961
public function create(string $className, string $typeName): Type
    {
        $description = 'To be used as a filter for objects of type `' . Utils::getTypeName($className) . '`';

        $fieldsGetter = function () use ($className, $typeName): array {
            $configuration = [
                [
                    'name' => 'groups',
                    'type' => Type::listOf(Type::nonNull($this->getGroupType($className, $typeName))),
                ],
            ];

            return $configuration;
        };

        $filterType = new InputObjectType([
            'name' => $typeName,
            'description' => $description,
            'fields' => $fieldsGetter,
        ]);
        $this->types->registerInstance($filterType);

        return $filterType;
    }
969781
protected function getTypeForClassName($className)
    {
        if (empty($this->rootNamespace)) {
            return $className;
        }
        return $this->stripNamespace($this->rootNamespace, $className);
    }
1063036
public function createEntity($className, array $fields = [])
    {
        $metadata = $this->getEntityMetadata($className);

        if (is_null($metadata)) {
            return null;
        }

        $reflection = $metadata->getReflectionClass();

        try {
            $entity = $reflection->newInstance();
        } catch (\Exception $e) {
            $entity = $reflection->newInstanceWithoutConstructor();
        }

        foreach ($fields as $fieldName => $fieldValue) {
            if (self::IDENTITY === $fieldName) {
                $property = $reflection->getProperty($this->getEntityIdName($className));
            } else {
                $property = $reflection->getProperty($fieldName);
            }

            try {
                $property->setValue($entity, $fieldValue);
            } catch (\Exception $e) {
                $property->setAccessible(true);
                $property->setValue($entity, $fieldValue);
                $property->setAccessible(false);
            }
        }

        return $entity;
    }
602434
private function getCollectionItemType($className, $fieldName)
    {
        $serializerMetadata = $this->serializerMetadataFactory->getMetadataForClass($className);
        if ($serializerMetadata === null) {
            return null;
        }
        if (!isset($serializerMetadata->propertyMetadata[$fieldName])) {
            return null;
        }

        $type = $serializerMetadata->propertyMetadata[$fieldName]->type;
        return isset($type['name'], $type['params'][0]['name']) && $type['name'] === 'array' ?
            $type['params'][0]['name'] :
            null;
    }
224086
public function getEntityHydrator($className)
    {
        if (!array_key_exists($className, $this->entityHydrators)) {
            $this->entityHydrators[$className] = new EntityHydrator($className, $this);
        }

        return $this->entityHydrators[$className];
    }
5831
public function createNew($className)
    {
        $constructArguments = func_get_args();
        $object = $this->_createNew( ...$constructArguments);
        
        $traits = class_uses($object);

        if (isset($traits[Framework::class]) == true) {
            $object->setContainer($this->container);
        }

        return $object;
    }
248145
protected function getParentTypeName($typeName)
    {
        if ($typeName == IObjectType::BASE) {
            return null;
        }

        if (strpos($typeName, IObjectType::NAME_SEPARATOR) === false) {
            return IObjectType::BASE;
        }

        $parentTypes = explode(IObjectType::NAME_SEPARATOR, $typeName);
        array_pop($parentTypes);

        return implode(IObjectType::NAME_SEPARATOR, $parentTypes);
    }
149407
protected function _phpTypeToAS($typename)
    {
        if (class_exists($typename)) {
            $vars = get_class_vars($typename);

            if (isset($vars['_explicitType'])) {
                return $vars['_explicitType'];
            }
        }

        if (false !== ($asname = Zend_Amf_Parse_TypeLoader::getMappedClassName($typename))) {
            return $asname;
        }

        return $typename;
    }
481604
private function getGroupType(string $className, string $typeName): InputObjectType
    {
        $fields = [
            [
                'name' => 'groupLogic',
                'type' => $this->types->get('LogicalOperator'),
                'description' => 'The logic operator to be used to append this group',
                'defaultValue' => 'AND',
            ],
            [
                'name' => 'conditionsLogic',
                'type' => $this->types->get('LogicalOperator'),
                'description' => 'The logic operator to be used within all conditions in this group',
                'defaultValue' => 'AND',
            ],
            $this->filterGroupConditionTypeFactory->getField($className),
        ];

        // Only create join type, if there is anything to join on
        if ($this->filterGroupJoinTypeFactory->canCreate($className)) {
            $fields[] = $this->filterGroupJoinTypeFactory->getField($className);
        }

        $conditionType = new InputObjectType([
            'name' => $typeName . 'Group',
            'description' => 'Specify a set of joins and conditions to filter `' . Utils::getTypeName($className) . '`',
            'fields' => $fields,
        ]);
        $this->types->registerInstance($conditionType);

        return $conditionType;
    }
703717
public function create(string $className, array $options)
    {
        $reflectionClass = $this->getReflectionClass($className);
        $options = Options::fromArray($options);

        $arguments = $this->resolveArguments($reflectionClass, $options);

        return new $className(...$arguments);
    }
52975
public static function parse($typeName)
    {
        $normalize = array("int" => self::INTEGER_NAME, 
            "bool" => self::BOOLEAN_NAME, 
            "double" => self::FLOAT_NAME,
            "real" => self::FLOAT_NAME,
            "long" => self::INTEGER_NAME);

        if (isset($normalize[$typeName]))
            $typeName = $normalize[$typeName];

        if (self::$cachedTypes === null)
        {
            self::$cachedTypes = array(
                self::INTEGER_NAME => new PrimitiveType(self::INTEGER_NAME),
                self::FLOAT_NAME => new PrimitiveType(self::FLOAT_NAME),
                self::STRING_NAME => new PrimitiveType(self::STRING_NAME),
                self::BOOLEAN_NAME => new PrimitiveType(self::BOOLEAN_NAME),
                self::MIXED_NAME => new PrimitiveType(self::MIXED_NAME),
                self::RESOURCE_NAME => new PrimitiveType(self::RESOURCE_NAME),
                self::OBJECT_NAME => new PrimitiveType(self::OBJECT_NAME),
                self::NULL_NAME => new PrimitiveType(self::NULL_NAME),
                self::CALLABLE_NAME => new PrimitiveType(self::CALLABLE_NAME));
        }

        if (isset(self::$cachedTypes[$typeName]))
            return self::$cachedTypes[$typeName];

        return null;
    }
444855
protected function createProjectClass($className)
    {
        $arguments = func_get_args();
        array_shift($arguments);

        return $this->_projectLoader->createClass($className, $arguments);
    }
278572
public static function generate(string $typeName, array $typeFields): string
    {
        $mutationName = 'create' . $typeName;

        $arguments = RelationArgumentGenerator::generate($typeFields);
        $arguments = array_merge($arguments, InputFieldsArgumentGenerator::generate($typeFields));

        if (count($arguments) < 1) {
            return '';
        }

        $mutation = sprintf('    %s(%s)', $mutationName, implode(', ', $arguments));
        $mutation .= sprintf(': %1$s @create(model: "%1$s")', $typeName);

        if (config('lighthouse-utils.authorization')) {
            $permission = sprintf('create%1$s', $typeName);
            $mutation .= sprintf(' @can(if: "%1$s", model: "User")', $permission);
        }

        GraphQLSchema::register($mutationName, $typeName, 'mutation', $permission ?? null);

        return $mutation;
    }
1260330
private function setObjectForClass(ClassName $className, array $data)
    {
        $fqdnClass = $className->getValue();
        $object = new $fqdnClass();

        foreach ($data as $attribute => $value) {
            $configurationObject = $this->configuration->getConfigurationObjectForClass($className);
            $type = $configurationObject->getTypeForAttribute($attribute);

            $this->processDeserializeForType($type, $object, $value);
        }

        return $object;
    }
249820
public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type)
    {
        return new self(sprintf(
            "It is not possible to set id field '%s' to type '%s' in entity class '%s'. The type '%s' "
                . 'requires conversion SQL which is not allowed for identifiers.',
            $fieldName,
            $type,
            $className,
            $type
        ));
    }
826473
protected function typeToClassName($typeName)
    {
        $classBase = Type::studlyCaps($typeName).'Type';

        $class = __NAMESPACE__."\\$classBase";

        if (class_exists($class)) {
            return $class;
        }

        $class = __NAMESPACE__."\UnitTypes\\$classBase";

        if (class_exists($class)) {
            return $class;
        }

        throw new ResourceNotFoundException("XType class for $typeName not found");
    }
794183
public static function get_type_by_typename($typename) {
        global $DB;
        $cache = cache::make('core', 'repositories');
        if (($repositorytype = $cache->get('typename:'. $typename)) === false) {
            $repositorytype = null;
            if ($record = $DB->get_record('repository', array('type' => $typename))) {
                $repositorytype = new repository_type($record->type, (array)get_config($record->type), $record->visible, $record->sortorder);
                $cache->set('typeid:'. $record->id, $repositorytype);
            }
            $cache->set('typename:'. $typename, $repositorytype);
        }
        return $repositorytype;
    }