protected function registerBundleTypes($path, $namespace)
    {
        $finder = new Finder();
        foreach ($finder->in($path)->name('/Type.php$/')->getIterator() as $file) {
            $className = preg_replace('/.php$/', null, $file->getFilename());

            if ($file->getRelativePath()) {
                $subNamespace = str_replace('/', '\\', $file->getRelativePath());
                $fullyClassName = $namespace.'\\Type\\'.$subNamespace.'\\'.$className;
            } else {
                $fullyClassName = $namespace.'\\Type\\'.$className;
            }

            if (class_exists($fullyClassName)) {
                $ref = new \ReflectionClass($fullyClassName);
                if ($ref->isSubclassOf(Type::class) && $ref->isInstantiable()) {
                    $requiredParams = false;
                    foreach ($ref->getConstructor()->getParameters() as $parameter) {
                        if ($parameter->getClass() && $parameter->getClass()->implementsInterface(DefinitionInterface::class)) {
                            continue 2;
                        }
                    }

                    if ($requiredParams) {
                        $error = sprintf('The graphql type defined in class "%s" is not instantiable because has some required parameters in the constructor.', $fullyClassName);
                        throw new \LogicException($error);
                    }
                    /** @var Type $instance */
                    $instance = $ref->newInstance();
                    TypeRegistry::addTypeMapping($instance->name, $fullyClassName);
                }
            }
        }
    }
protected function registerBundleTypes($path, $namespace)
    {
        $finder = new Finder();
        foreach ($finder->in($path)->name('/Type.php$/')->getIterator() as $file) {
            $className = preg_replace('/.php$/', null, $file->getFilename());

            if ($file->getRelativePath()) {
                $subNamespace = str_replace('/', '\\', $file->getRelativePath());
                $fullyClassName = $namespace.'\\Type\\'.$subNamespace.'\\'.$className;
            } else {
                $fullyClassName = $namespace.'\\Type\\'.$className;
            }

            if (class_exists($fullyClassName)) {
                $ref = new \ReflectionClass($fullyClassName);
                if ($ref->isSubclassOf(Type::class) && $ref->isInstantiable()) {
                    $requiredParams = false;
                    foreach ($ref->getConstructor()->getParameters() as $parameter) {
                        if ($parameter->getClass() && $parameter->getClass()->implementsInterface(DefinitionInterface::class)) {
                            continue 2;
                        }
                    }

                    if ($requiredParams) {
                        $error = sprintf('The graphql type defined in class "%s" is not instantiable because has some required parameters in the constructor.', $fullyClassName);
                        throw new \LogicException($error);
                    }
                    /** @var Type $instance */
                    $instance = $ref->newInstance();
                    TypeRegistry::addTypeMapping($instance->name, $fullyClassName);
                }
            }
        }
    }
protected function registerBundleTypes ( $ path , $ namespace ) { $ finder = new Finder ( ) ; foreach ( $ finder -> in ( $ path ) -> name ( '/Type.php$/' ) -> getIterator ( ) as $ file ) { $ className = preg_replace ( '/.php$/' , null , $ file -> getFilename ( ) ) ; if ( $ file -> getRelativePath ( ) ) { $ subNamespace = str_replace ( '/' , '\\' , $ file -> getRelativePath ( ) ) ; $ fullyClassName = $ namespace . '\\Type\\' . $ subNamespace . '\\' . $ className ; } else { $ fullyClassName = $ namespace . '\\Type\\' . $ className ; } if ( class_exists ( $ fullyClassName ) ) { $ ref = new \ ReflectionClass ( $ fullyClassName ) ; if ( $ ref -> isSubclassOf ( Type :: class ) && $ ref -> isInstantiable ( ) ) { $ requiredParams = false ; foreach ( $ ref -> getConstructor ( ) -> getParameters ( ) as $ parameter ) { if ( $ parameter -> getClass ( ) && $ parameter -> getClass ( ) -> implementsInterface ( DefinitionInterface :: class ) ) { continue 2 ; } } if ( $ requiredParams ) { $ error = sprintf ( 'The graphql type defined in class "%s" is not instantiable because has some required parameters in the constructor.' , $ fullyClassName ) ; throw new \ LogicException ( $ error ) ; } /** @var Type $instance */ $ instance = $ ref -> newInstance ( ) ; TypeRegistry :: addTypeMapping ( $ instance -> name , $ fullyClassName ) ; } } } }
Register all GraphQL types for given path

@param string $path
@param string $namespace

@throws \ReflectionException
Register all GraphQL types for given path