Adds aliases

@param \Twig_Loader_Filesystem $loader
@param array $aliases
778297
protected function addAliases($loader, $aliases)
    {
        foreach ($aliases as $alias => $path) {
            if (is_array($path)) {
                $this->addAliases($loader, $path);
            } elseif (is_string($path) && is_dir($path)) {
                $loader->addPath($path, substr($alias, 1));
            }
        }
    }
632438
protected function registerAliases()
    {
        $loader = $this->aliasLoader;

        $this->app->booting(function() use ($loader) {
            foreach ($this->aliases as $class => $alias) {
                $loader->alias($class, $alias);
            }
        });
    }
65603
function attach(iLoader $loader, $priority = 0)
    {
        $this->_t_loader_aggregate_getQueue()->insert($loader, $priority);

        $loaderClass = get_class($loader);
        $loaderClass = $this->_normalizeLoaderName($loaderClass);
        $this->_t_loader_aggregate_Names[$loaderClass] = $loader;

        return $this;
    }
103880
protected function loadConfigurationFile(array $config, XmlFileLoader $loader)
    {
        foreach ($config as $filename) {
            if (file_exists($file = sprintf('%s/%s.xml', $this->getConfigurationDirectory(), $filename))) {
                $loader->load($file);
            }
        }
    }
678308
public function getTwigCompiler($loader)
    {
        $this->twig = new Twig_Environment($loader, array(
           'cache'       => storage_path().'/views',
           'autoescape'  => false,
           'auto_reload' => true
        ));

        // Hook twig to do what you want.
        $hooks = $this->config->get('theme.engines.twig.hooks');
        $this->twig = $hooks($this->twig);

        // Get facades aliases.
        $aliases = $this->config->get('app.aliases');

        // Laravel alias to allow.
        $allows = $this->config->get('theme.engines.twig.allows');

        foreach ($aliases as $alias => $class)
        {
            // Nothing allow if not exists in twig config.
            if ( ! in_array($alias, $allows)) continue;

            // Clasname with namspacing.
            $className = '\\'.$alias;

            // Some method is not in facade like Str.
            if ( ! method_exists($className, 'getFacadeRoot'))
            {
                $this->twig->addGlobal($alias, new $className());
            }
            // Method support real facade.
            else
            {
                $this->twig->addGlobal($alias, $className::getFacadeRoot());
            }
        }

        /*$function = new Twig_SimpleFunction('call', function($function)
        {
            $args = func_get_args();
            $args = array_splice($args, 1);

            return call_user_func_array($function, $args);
        });

        $this->twig->addFunction($function);*/

        return $this->twig;
    }
1247313
protected function configureLoader(LoaderInterface $loader)
    {
        if ($loader instanceof Base) {
            $loader->setORM($this->getORM());
            if ($this->logger) {
                $loader->setLogger($this->logger);
            }
        }
        if (is_callable(array($loader, 'addProvider'))) { // new in Alice 1.7.2
            $loader->addProvider($this->providers);
        } else { // BC path
            $loader->setProviders($this->providers);
        }
    }
1289937
protected function addFallbackPaths($loader, $theme)
    {
        foreach ($this->twigFallbackPaths as $namespace => $path) {
            $path = Yii::getAlias($path);
            if (!is_dir($path)) {
                continue;
            }

            if (is_string($namespace)) {
                $loader->addPath($path, $namespace);
            } else {
                $loader->addPath($path);
            }
        }

        if ($theme instanceOf \yii\base\Theme && is_array($theme->pathMap)) {
            $pathMap = $theme->pathMap;

            if (isset($pathMap['@app/views'])) {
                foreach ((array)$pathMap['@app/views'] as $path) {
                    $path = Yii::getAlias($path);
                    if (is_dir($path)) {
                        $loader->addPath($path, $this->twigViewsNamespace);
                    }
                }
            }

            if (isset($pathMap['@app/modules'])) {
                foreach ((array)$pathMap['@app/modules'] as $path) {
                    $path = Yii::getAlias($path);
                    if (is_dir($path)) {
                        $loader->addPath($path, $this->twigModulesNamespace);
                    }
                }
            }

            if (isset($pathMap['@app/widgets'])) {
                foreach ((array)$pathMap['@app/widgets'] as $path) {
                    $path = Yii::getAlias($path);
                    if (is_dir($path)) {
                        $loader->addPath($path, $this->twigWidgetsNamespace);
                    }
                }
            }
        }

        $defaultViewsPath = Yii::getAlias('@app/views');
        if (is_dir($defaultViewsPath)) {
            $loader->addPath($defaultViewsPath, $this->twigViewsNamespace);
        }

        $defaultModulesPath = Yii::getAlias('@app/modules');
        if (is_dir($defaultModulesPath)) {
            $loader->addPath($defaultModulesPath, $this->twigModulesNamespace);
        }

        $defaultWidgetsPath = Yii::getAlias('@app/widgets');
        if (is_dir($defaultWidgetsPath)) {
            $loader->addPath($defaultWidgetsPath, $this->twigWidgetsNamespace);
        }
    }
513861
public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/../config/config.yml');

        foreach ($this->extraConfigFiles as $configFile) {
            $loader->load($configFile);
        }
    }
991505
protected function addAliasRoutes($aliasRoutes)
    {
        $aliasRoutes = (array) $aliasRoutes;
        foreach ($aliasRoutes as $aliasRoute)
        {
            $aliasRoute = (string) $aliasRoute;
            $this->aliasRouteNames[$aliasRoute] = $aliasRoute;
        }

        return $this;
    }
516405
public function pushLoader(VirtFsLoader $loader)
    {
        if (!in_array($loader,$this->loaders)) {
            $this->loaders[] = $loader;
        }
        return $this;
    }
603168
public function loader(callable $loader, string ...$types): BuilderInterface
    {
        $this->resolver->loader($loader, ...$types);

        return $this;
    }
733936
public function addResource(ResourceInterface $resource, $loader)
    {
        $this->resources[$loader][] = $resource;
        $this->loaded = false;
    }
380587
public function registerLoader($alias, $loader)
    {
        if ($this->hasLoader($alias)) {
            throw new \RuntimeException(sprintf('Alias "%s" already used by another form loader', $alias));
        }

        $this->loaders[$alias] = $loader;
    }
1202215
public static function setLoader($loader) {
    if (!$loader) {
      self::$_loader = NULL;
      return;
    }
    if ($loader instanceof FluentDOM\Loadable) {
      self::$_loader = $loader;
      return;
    }
    throw new FluentDOM\Exceptions\InvalidArgument(
      'loader', [Loadable::class]
    );
  }
916486
public function loadAliasesFrom($path, $namespace, $key = 'aliases')
    {
        // Get the alias loader
        $loader = Loader::getInstance();

        // Prepare key for config line
        $key = ! is_null($key) ? '.' . $key : null;

        // Wrapped in a try catch because Finder squawks when there is no directory
        try{

            // Load the namespaced config files
            $files = Finder::create()->files()->name('*.php')->in($path);
            foreach($files as $file)
            {
                // Construct the config line where aliases are defined
                $filename = basename($file->getRealPath(), '.php');
                $line = $namespace . '::' . $filename . $key;

                // Load each of the aliases
                $aliases = config($line, []);
                foreach( $aliases as $alias => $class)
                {
                    $loader->alias($alias, $class);
                }
            }

        // Silently ignore Finder exceptions
        } catch( InvalidArgumentException $e){}
    }
281914
public static function setAliases(array $aliases)
    {
        foreach ($aliases as $name => $path) {
            self::setAlias($name, $path);
        }
    }
1157374
public function addLoaders(array $loaders) {
        foreach ($loaders as $loader) {
            if (is_string($loader)) {
                $loader = new $loader();
            }

            if (!$loader instanceof InputLoaderInterface) {
                $name = is_object($loader) ? get_class($loader) : (string) $loader;
                throw new InvalidArgumentException('Given loader (' . $name . ') does not implement LoaderInterface', 500);
            }

            $this->registerLoader($loader);
        }

        return $this;
    }