src/Core/Renderer/RendererManager.php
public function getRenderer($type = self::PHP, $config = [])
    {
        $type = strtolower($type);

        $class = sprintf('Windwalker\Core\Renderer\%sRenderer', ucfirst($type));

        if (!class_exists($class)) {
            $class = sprintf('Windwalker\Renderer\%sRenderer', ucfirst($type));
        }

        if (!class_exists($class)) {
            throw new \DomainException(sprintf('%s renderer not supported.', $type));
        }

        if ($type === 'blade') {
            if (empty($config['cache_path'])) {
                $config['cache_path'] = $this->config->get('path.cache') . '/renderer';
            }
        }

        if ($type === 'edge') {
            if (empty($config['cache_path']) && !isset($config['cache'])) {
                $config['cache_path'] = $this->config->get('path.cache') . '/renderer';
            }
        }

        if ($type === 'twig') {
            if (empty($config['path_separator'])) {
                $config['path_separator'] = '.';
            }
        }

        /** @var AbstractRenderer|CoreRendererInterface|GlobalVarsTrait $renderer */
        $renderer = new $class(static::getGlobalPaths(), $config);

        $renderer->setPackageFinder($this->finder);
        $renderer->setGlobals($this->getGlobals());

        return $renderer;
    }
public function getRenderer($type = self::PHP, $config = [])
    {
        $type = strtolower($type);

        $class = sprintf('Windwalker\Core\Renderer\%sRenderer', ucfirst($type));

        if (!class_exists($class)) {
            $class = sprintf('Windwalker\Renderer\%sRenderer', ucfirst($type));
        }

        if (!class_exists($class)) {
            throw new \DomainException(sprintf('%s renderer not supported.', $type));
        }

        if ($type === 'blade') {
            if (empty($config['cache_path'])) {
                $config['cache_path'] = $this->config->get('path.cache') . '/renderer';
            }
        }

        if ($type === 'edge') {
            if (empty($config['cache_path']) && !isset($config['cache'])) {
                $config['cache_path'] = $this->config->get('path.cache') . '/renderer';
            }
        }

        if ($type === 'twig') {
            if (empty($config['path_separator'])) {
                $config['path_separator'] = '.';
            }
        }

        /** @var AbstractRenderer|CoreRendererInterface|GlobalVarsTrait $renderer */
        $renderer = new $class(static::getGlobalPaths(), $config);

        $renderer->setPackageFinder($this->finder);
        $renderer->setGlobals($this->getGlobals());

        return $renderer;
    }
public function getRenderer ( $ type = self :: PHP , $ config = [ ] ) { $ type = strtolower ( $ type ) ; $ class = sprintf ( 'Windwalker\Core\Renderer\%sRenderer' , ucfirst ( $ type ) ) ; if ( ! class_exists ( $ class ) ) { $ class = sprintf ( 'Windwalker\Renderer\%sRenderer' , ucfirst ( $ type ) ) ; } if ( ! class_exists ( $ class ) ) { throw new \ DomainException ( sprintf ( '%s renderer not supported.' , $ type ) ) ; } if ( $ type === 'blade' ) { if ( empty ( $ config [ 'cache_path' ] ) ) { $ config [ 'cache_path' ] = $ this -> config -> get ( 'path.cache' ) . '/renderer' ; } } if ( $ type === 'edge' ) { if ( empty ( $ config [ 'cache_path' ] ) && ! isset ( $ config [ 'cache' ] ) ) { $ config [ 'cache_path' ] = $ this -> config -> get ( 'path.cache' ) . '/renderer' ; } } if ( $ type === 'twig' ) { if ( empty ( $ config [ 'path_separator' ] ) ) { $ config [ 'path_separator' ] = '.' ; } } /** @var AbstractRenderer|CoreRendererInterface|GlobalVarsTrait $renderer */ $ renderer = new $ class ( static :: getGlobalPaths ( ) , $ config ) ; $ renderer -> setPackageFinder ( $ this -> finder ) ; $ renderer -> setGlobals ( $ this -> getGlobals ( ) ) ; return $ renderer ; }
Create a renderer object and auto inject the global paths.

@param   string $type   Renderer engine name, php, blade, twig or mustache.
@param   array  $config Renderer config array.

@return  AbstractRenderer|CoreRendererInterface
@since   2.0
Create a renderer object and auto inject the global paths .