protected function getSmarty()
    {
        $smarty = new \Smarty();

        $smarty->template_dir = realpath(
            __DIR__ . DIRECTORY_SEPARATOR .
            'smarty' . DIRECTORY_SEPARATOR .
            'templates' . DIRECTORY_SEPARATOR
        );

        $smarty->compile_dir = realpath(static::SMARTY_COMPILE_DIR);
        if (!is_dir($smarty->compile_dir) || !is_writable($smarty->compile_dir)) {
            throw new \Exception(
                'Smarty compile directory ' . static::SMARTY_COMPILE_DIR .
                ' is not writable for user "' . get_current_user() . '". ' .
                'Please fix the permissions on this directory',
                static::ERROR_CODE_SMARTY_COMPILE_DIR_PERMISSIONS
            );
        }

        $smarty->left_delimiter = '{{';
        $smarty->right_delimiter = '}}';

        return $smarty;
    }