public function fetchTemplate(Request $request, $template)
    {
        if (!$this->view instanceof Twig) {
            throw new Exception("Twig provider not registered.");
        }

        foreach ($this->settings['view']['global'] as $key => $map) {
            $key = is_numeric($key) ? $map : $key;

            switch ($key) {
                case 'request':
                    $value = $request;
                    break;

                default:
                    $value = isset($this->container[$key]) ? $this->container[$key] : null;
                    break;
            }

            $this->view->getEnvironment()->addGlobal($map, $value);
        }

        $result = $this->view->fetch(
            $template . $this->settings['view']['extension'],
            $this->data->all()
        );

        return $result;
    }