public function setupEnvironment(Container $container)
    {
        $env = new Environment(
            $container->get('Minty\\AbstractTemplateLoader'),
            $this->getConfiguration('options')
        );

        /** @var $request \Miny\HTTP\Request */
        $request = $container->get('Miny\\HTTP\\Request');

        $env->addGlobalVariable('is_ajax', $request->isAjax());
        $env->addGlobalVariable('is_internal_request', $request->isSubRequest());

        $env->addExtension(new Core());
        $env->addExtension(new Optimizer());
        $env->addExtension($container->get(__NAMESPACE__ . '\\Extensions\\Miny'));

        if ($env->getOption('debug')) {
            $env->addExtension(new Debug());

            if ($this->getConfiguration('enable_node_tree_visualizer')) {
                $env->addExtension($container->get(__NAMESPACE__ . '\\Extensions\\Visualizer'));
            }
        }

        return $env;
    }