public static function createEnvironment($paths, \Symfony\Component\Translation\Translator $translator, $options = array())
    {
        $viewPath = $paths['base'] . '/' . DIRNAME_VIEWS;
        $twigBridgePath = $paths['lib'] . '/symfony/twig-bridge/Symfony/Bridge/Twig';

        $opts = array();
        if (Config::get('app.twig_debug')) {
            $opts['debug'] = true;
        } elseif ($paths['cache']) {
            $opts['cache'] = $paths['cache'];
        }
        $opts = array_merge_recursive($opts, $options);
        $twig = new Twig_Environment(new Twig_Loader_Filesystem(
            array(
                $twigBridgePath . '/Resources/views/Form',
            )
        ), $opts);

        if (is_object($translator)) {
            $twig->addExtension(
                new \Symfony\Bridge\Twig\Extension\TranslationExtension(
                    $translator
                )
            );
        }

        $twig->addExtension(
            new Concrete5Extension()
        );

        if (Config::get('app.package_dev_mode')) {
            $twig->addExtension(new Twig_Extension_Debug());
        }

        return $twig;
    }
public static function createEnvironment($paths, \Symfony\Component\Translation\Translator $translator, $options = array())
    {
        $viewPath = $paths['base'] . '/' . DIRNAME_VIEWS;
        $twigBridgePath = $paths['lib'] . '/symfony/twig-bridge/Symfony/Bridge/Twig';

        $opts = array();
        if (Config::get('app.twig_debug')) {
            $opts['debug'] = true;
        } elseif ($paths['cache']) {
            $opts['cache'] = $paths['cache'];
        }
        $opts = array_merge_recursive($opts, $options);
        $twig = new Twig_Environment(new Twig_Loader_Filesystem(
            array(
                $twigBridgePath . '/Resources/views/Form',
            )
        ), $opts);

        if (is_object($translator)) {
            $twig->addExtension(
                new \Symfony\Bridge\Twig\Extension\TranslationExtension(
                    $translator
                )
            );
        }

        $twig->addExtension(
            new Concrete5Extension()
        );

        if (Config::get('app.package_dev_mode')) {
            $twig->addExtension(new Twig_Extension_Debug());
        }

        return $twig;
    }
public static function createEnvironment ( $ paths , \ Symfony \ Component \ Translation \ Translator $ translator , $ options = array ( ) ) { $ viewPath = $ paths [ 'base' ] . '/' . DIRNAME_VIEWS ; $ twigBridgePath = $ paths [ 'lib' ] . '/symfony/twig-bridge/Symfony/Bridge/Twig' ; $ opts = array ( ) ; if ( Config :: get ( 'app.twig_debug' ) ) { $ opts [ 'debug' ] = true ; } elseif ( $ paths [ 'cache' ] ) { $ opts [ 'cache' ] = $ paths [ 'cache' ] ; } $ opts = array_merge_recursive ( $ opts , $ options ) ; $ twig = new Twig_Environment ( new Twig_Loader_Filesystem ( array ( $ twigBridgePath . '/Resources/views/Form' , ) ) , $ opts ) ; if ( is_object ( $ translator ) ) { $ twig -> addExtension ( new \ Symfony \ Bridge \ Twig \ Extension \ TranslationExtension ( $ translator ) ) ; } $ twig -> addExtension ( new Concrete5Extension ( ) ) ; if ( Config :: get ( 'app.package_dev_mode' ) ) { $ twig -> addExtension ( new Twig_Extension_Debug ( ) ) ; } return $ twig ; }
We need a context specific twig environment object because
a) The twig libraries or the Symfony twig bridge are not
available in the core so we cannot rely on their availability
any other way
b) We'll need to have a single twig environment per twig cache
directory.
We need a context specific twig environment object because a ) The twig libraries or the Symfony twig bridge are not available in the core so we cannot rely on their availability any other way b ) We ll need to have a single twig environment per twig cache directory .