Get the Twig environment instance.

@return \Twig_Environment
974190
public function instance() {
		if ( ! isset( self::$environment ) ) {
			self::$environment = $this->boot();
		}

		return self::$environment;
	}
1299930
public static function getEnvironment()
    {
        if (self::$_environment !== null) {
            return self::$_environment;
        }

        $language      = setlocale(LC_ALL, 0);
        $languages     = explode(';', $language);
        $languagearray = array();

        foreach ($languages as $locale) {
            if (strpos($locale, '=') !== false) {
                $language = substr($locale, strpos($locale, '='));
                $language = substr($language, 1);
            }

            if ($language !== 'C') {
                if (strpos($language, '.') !== false) {
                    $language = substr($language, 0, strpos($language, '.'));
                } else if (strpos($language, '@') !== false) {
                    $language = substr($language, 0, strpos($language, '@'));
                }

                $language = str_ireplace(
                    array_keys(Zend_Locale_Data_Translation::$languageTranslation),
                    array_values(Zend_Locale_Data_Translation::$languageTranslation),
                    (string) $language
                );

                $language = str_ireplace(
                    array_keys(Zend_Locale_Data_Translation::$regionTranslation),
                    array_values(Zend_Locale_Data_Translation::$regionTranslation),
                    $language
                );

                if (isset(self::$_localeData[$language]) === true) {
                    $languagearray[$language] = 1;
                    if (strpos($language, '_') !== false) {
                        $languagearray[substr($language, 0, strpos($language, '_'))] = 1;
                    }
                }
            }
        }

        self::$_environment = $languagearray;
        return $languagearray;
    }
1317065
public function environment()
    {
        if ($this->environment) {
            return $this->environment;
        }

        if (!$this->environmentProvider) {
            $this->environment = static::PRODUCTION;
            return $this->environment;
        }

        $this->setEnvironment(call_user_func($this->environmentProvider, $this));

        return $this->environment;
    }
1140280
public function getTwigExtras()
    {
        if (!isset($this->config['twig']) || empty($this->config['twig'])) {
            return array();
        }
        $array = $this->config['twig'];
        if (!is_array($array)) {
            $array = array($array);
        }
        return $array;
    }
695449
public static function getEngine()
    {
        if (!static::$engine) {
            $loader = new \Twig_Loader_Filesystem();
            $loader->setPaths(__DIR__ . '/../../views');
            foreach (app('extension')->getExtensions() as $extension) {
                $path = $extension->getPath() . '/views';
                if (file_exists($path)) {
                    $loader->setPaths($path, $extension->getPackage());
                }
            }
            static::$engine = new \Twig_Environment($loader);
            static::$engine->addGlobal('assets', static::getAssetManager());
            static::$engine->addGlobal('config', Config::get());
        }
        return static::$engine;
    }
981181
public function getCurrentPage()
    {
        $givenRelativeFile = str_replace(
            $this->environment->getSourceDirectory(),
            '',
            $this->environment->getSourceFile()
        );

        return str_replace('.twig', '', $givenRelativeFile);
    }
1292762
public function setTwigEnvironment()
    {
        if (!$this->template instanceof Template) {
            return $this;
        }

        $this->template->configure($this);
        $controller = $this->getControllerName();
        $this->layout = Inflector::toDirectorySeparator($this->layout);

        if ($this->layout == '') {
            $this->layout = strtolower($controller);
        }
        $this->setViewPath();

        if (!is_object(static::$twigEnvironment)) {
            static::$twigEnvironment = $this->template->setEnvironment();
        }

        if ($this->isDebugModeOn()) {
            $this->template->addExtension();
        }
    }
1340897
public function buildTwigEnvironmentOptions(TwigConfig $config) {
        $options = [
            'debug' => $config->getDebug(),
        ];

        if ($config->getCharset() !== null) {
            $options['charset'] = $config->getCharset();
        }

        if ($config->getBaseTemplateClass() !== null) {
            $options['base_template_class'] = $config->getBaseTemplateClass();
        }

        if ($config->getCache() !== null) {
            $options['cache'] = $config->getCache();
        }

        if ($config->getAutoReload() !== null) {
            $options['auto_reload'] = $config->getAutoReload();
        }

        if ($config->getAutoEscape() !== null) {
            $options['autoescape'] = $config->getAutoEscape();
        }

        if ($config->getStrictVariables() !== null) {
            $options['strict_variables'] = $config->getStrictVariables();
        }

        if ($config->getOptimizations() !== null) {
            $options['optimizations'] = $config->getOptimizations();
        }

        return $options;
    }
1160415
private function getEnvironment()
  {
    $env = new \Dotenv\Dotenv($this->basePath);
    $env->load();
    $this->env['env'] = getenv('APP_ENV');
    $this->env['debug'] = getenv('APP_DEBUG');
    $this->env['appSecret'] = getenv('APP_KEY');
  }
65669
public function getEnvironments()
    {
        if (isset($this->values['environments'])) {
            $environments = [];
            foreach ($this->values['environments'] as $key => $value) {
                if (is_array($value)) {
                    $environments[$key] = $value;
                }
            }

            return $environments;
        }

        return null;
    }
1285104
public function getTwig()
    {
        if (is_null($this->_twig)) {
            $this->_twig = new Twig_Environment(
                new Twig_Loader_Filesystem($this->_paths),
                [
                    'debug' => true,
                ]
            );
            $this->_twig->addExtension(new Twig_Extension_Debug());
            $this->_twig->addExtension(new SlickTwigExtension());
        }
        return $this->_twig;
    }
982335
public function getFilesetTwig() {
    $finder = $this->getTwigFilesetFinder();
    $finder->in([$this->getConfigValue('docroot') . '/themes/custom']);
    $finder->in([$this->getConfigValue('docroot') . '/modules/custom']);

    return $finder;
  }
298534
public function get()
    {
        $result = $this->_environment ? $this->_environment->getenv($this->_name) : getenv($this->_name);

        return $result !== false ? $result : null;
    }
203894
public function getConfigTreeBuilder()
    {
        $builder = new TreeBuilder();
        $twig    = $builder->root('twig');
        {
            $twig->children()->scalarNode('template_dir');
            $twig->children()->scalarNode('cache_dir')->defaultValue(null);
            $twig->children()->scalarNode('asset_base')->defaultValue('');
            $twig->children()->variableNode('globals')->defaultValue([]);
        }

        return $builder;
    }
892781
protected function envPath()
    {
        if (method_exists($this->laravel, 'environmentFilePath')) {
            return $this->laravel->environmentFilePath();
        }

        return $this->laravel->basePath('.env');
    }
971836
public function create(): \Twig\Environment
    {
        $twig = new \Twig\Environment($this->loader, $this->options);
        $modules = (new Provider($twig))->modules();

        foreach ($modules as $module) {
            if (!$module instanceof Module\Injectable) {
                continue;
            }

            // Add the module into Twig.
            $module->injectInto($twig);
        }

        return $twig;
    }
605040
private function getEnvironment()
    {
        $paths         = $this->config->paths;
        $paths['root'] = $this->root;
        return new \Taniko\Saori\Generator\Environment(
            $this->getMaker(),
            $this->getTwigEnv("{$this->theme_dir}/twig"),
            $paths
        );
    }