Register all GraphQL types for given path

@param string $path
@param string $namespace

@throws \ReflectionException
325598
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);
                }
            }
        }
    }
294854
protected function createDirFromNamespace($path, $namespace = null)
    {
        if ($namespace) {
            $path .= '/' . str_replace('\\', '/', trim($namespace, '\\'));
            if (is_dir($path)) {
                return $path . '/';
            }
            if (file_exists($path)) {
                throw new \Exception(sprintf('Path %s already exists', $path));
            }
            mkdir($path, 0777, true);
        }

        return $path;
    }
649822
public function loadFolder($path, $namespace = '__main__')
  {
      if (is_dir($path)) {
          $files = glob($path.'*.php');
          if (!defined('DS')) {
              define('DS', DIRECTORY_SEPARATOR);
          }
          foreach ($files as $file) {
              $shell = explode(DS, $file);
              $fileName = end($shell);
              $fileName = explode('.', $fileName, -1);
              $prefix = '';
              if (count($fileName) == 2) {
                  $prefix = reset($fileName).'.';
                  $locale = end($fileName);
              } else {
                  $locale = end($fileName);
              }
              $translations = require $file;
              $translations = array_dot($translations, $prefix);

              // merge $namespace arrays with prefixed arrays if exists
              if (isset($this->translations[$locale])) {
                  if (isset($this->translations[$locale][$namespace])) {
                      $translations = array_merge($this->translations[$locale][$namespace], $translations);
                  }
              }

              // Save the values in our instance array
              $this->translations[$locale][$namespace] = $translations;
          }
      }
  }
330777
public function package($package, $namespace = null, $path = null)
	{
		$namespace = $this->getPackageNamespace($package, $namespace);

		$path = $path ?: $this->guessPackagePath();

		//ChangeLog: Configuration setup removed


		// Next we will check for any "language" components. If language files exist
		// we will register them with this given package's namespace so that they
		// may be accessed using the translation facilities of the application.
		$lang = $path.'/lang';

		if ($this->app['files']->isDirectory($lang))
		{
			$this->app['translator']->addNamespace($namespace, $lang);
		}

		// Next, we will see if the application view folder contains a folder for the
		// package and namespace. If it does, we'll give that folder precedence on
		// the loader list for the views so the package views can be overridden.
		$appView = $this->getAppViewPath($package);

		if ($this->app['files']->isDirectory($appView))
		{
			$this->app['view']->addNamespace($namespace, $appView);
		}

		// Finally we will register the view namespace so that we can access each of
		// the views available in this package. We use a standard convention when
		// registering the paths to every package's views and other components.
		$view = $path.'/views';

		if ($this->app['files']->isDirectory($view))
		{
			$this->app['view']->addNamespace($namespace, $view);
		}
	}
812035
public function addAnnotationNamespace($namespace, $path = null)
    {
        $this->namespaces[] = $namespace;

        return $this->registerAnnotationsPathWithRegistry(
            $path ?: $this->getPathFromNamespace($namespace)
        );
    }
565287
public function addConfigComponent($package, $namespace, $path)
    {
        if ($this->hasPackageRepository()) {
            $this->app->make('config')->package($package, $path, $namespace);
        }
    }
1186973
private function addPath(& $list, $path, $namespace)
    {
        if ($namespace !== null) {
            $paths = [$namespace => $path];
        } else {
            $paths = is_array($path) ? $path : ['' => $path];
        }

        foreach ($paths as $ns => $directories) {
            $this->addNamespacePaths($list, ltrim($ns, '0..9'), $directories);
        }
    }
1016201
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
    {
        $path = rtrim($path, '/\\');

        if (!isset($this->paths[$namespace])) {
            $this->paths[$namespace][] = $path;
        } else {
            array_unshift($this->paths[$namespace], $path);
        }
    }
333863
public static function set($namespace, $path)
    {
        $namespace = trim($namespace, '\\');
        $path = rtrim($path, '/');

        if (!isset(self::$_namespace_list[$namespace])) {
            self::$_namespace_list[$namespace] = [];
        }

        self::$_namespace_list[$namespace][] = $path;
    }
23608
private function registerAutoload($fqcn, $path)
    {
        $namespace = str_replace(strrchr($fqcn, '\\'), '', $fqcn);
        $psr0 = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);

        // A part of the namespace should match a part of the path (PSR-0 standard)
        if (substr_count($path, $psr0) == 0) {
            throw new \RuntimeException('Boomgo annotation parser support only PSR-0 project structure');
        }

        $baseDirectory = str_replace($psr0, '', dirname($path));
        $partNamespace = explode('\\', $namespace);
        $baseNamespace = $partNamespace[0];

        spl_autoload_register(function($class) use ($baseNamespace, $baseDirectory) {
            if (0 === strpos($class, $baseNamespace)) {
                $path = $baseDirectory.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
                if (!stream_resolve_include_path($path)) {
                    return false;
                }
                require_once $path;

                return true;
            }
        });
    }
1237685
protected function loadViewsFrom($path, $namespace)
	{
		if (is_dir($appPath = $this->app->basePath() . '/resources/views/vendor/' . $namespace))
		{
			$this->app['view']->addNamespace($namespace, $appPath);
		}

		$this->app['view']->addNamespace($namespace, $path);
	}
1365714
public function addPath(string $path, string $namespace = self::DEFAULT_NAMESPACE)
    {
        // invalidate the cache
        $this->cache = $this->errorCache = [];

        $this->paths[$namespace][] = rtrim($path, '/\\');
    }
356959
public static function register($path)
	{
		self::$_path = $path;
		self::addPath($path);

		if ($loaders = spl_autoload_functions())
			array_map('spl_autoload_unregister', $loaders);
		else
			$loaders = function_exists('__autoload') ? array('__autoload') : array();

		array_unshift($loaders, array(__CLASS__, 'load'));
		array_map('spl_autoload_register', $loaders);
	}
159091
public static function add($key, $path)
    {
        self::$_registeredNamespaces[$key] = true;
        self::$_options['loader']->addPsr4($key, $path);
    }
424110
public function registerNamespace(PHPTAL_Namespace $ns)
    {
        $this->namespaces_by_uri[$ns->getNamespaceURI()] = $ns;
        $this->prefix_to_uri[$ns->getPrefix()] = $ns->getNamespaceURI();
        $prefix = strtolower($ns->getPrefix());
        foreach ($ns->getAttributes() as $name => $attribute) {
            $key = $prefix.':'.strtolower($name);
            $this->_dictionary[$key] = $attribute;
        }
    }
565373
protected function loadViewsFrom( $path, $namespace )
	{
		if ( is_dir( $appPath = Framework::fw()->basePath . '/resources/views/vendor/' . $namespace ) )
			Framework::get( 'view' )->addNamespace( $namespace, $appPath );

		Framework::get( 'view' )->addNamespace( $namespace, $path );
	}
816976
protected function loadFrontendRoutesFrom(string $path, ?string $namespace = '', array $attributes = []): void
    {
        $foundation = $this->app->make('orchestra.app');
        $attributes = $this->resolveRouteGroupAttributes($namespace, $attributes);

        $foundation->group($this->routeGroup, $this->routePrefix, $attributes, $this->getRouteLoader($path));
    }