Create Instance of Twig Environment

@since 1.0.0

@return \Twig\Environment The new instance of the environment
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;
    }
744951
public function registerTwigEngine()
    {
        /** @var Factory $factory */
        $factory = $this->app['view'];
        $factory->addExtension('twig', 'twig', function () {
            return new Twig($this->app['twig'], $this->app['view.finder']);
        });
    }
67533
public static function createFromEnvironment()
    {
        // Clean and update live global variables
        $variables = static::cleanEnvironment(Environment::getVariables());
        Environment::setVariables($variables); // Currently necessary for SSViewer, etc to work

        // Health-check prior to creating environment
        return static::createFromVariables($variables, @file_get_contents('php://input'));
    }
161521
public function setupTwig()
	{
		$twigLoader = new TwigLoader($this->viewManager);
		$config = [];

		if ($this->viewManager->cachePath)
		{
			$config['cache'] = $this->viewManager->cachePath.'twig/';
		}

		$this->twig = new Twig_Environment($twigLoader, $config);
	}
163874
private function initTwig(){
        if($this->twig === null){
            $this->twig = new Environment(
                new FilesystemLoader(__DIR__ . "/../resource/views"),
                [
                    "debug" => true,
                ]
            );

            $this->twig->addExtension(
                new \Twig\Extension\DebugExtension
            );
            $this->twig->addExtension(
                new \Twig\Extension\StringLoaderExtension
            );
            $this->twig->addFilter(new \Twig_Filter("md5", function($v){
                return md5($v);
            }));
        }
    }
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
        );
    }
676030
public static function newInstance()
    {
        $config = self::create();

        $config->username = 'null';
        $config->password = 'null';
        $config->credentials = ['null', 'null'];
        $config->bindtoInterface = 'null';
        $config->timeout = 5;

        return $config;
    }
1358128
public static function parser()
	{
		if ( ! empty(static::$_parser))
		{
			static::$_parser->setLoader(static::$_parser_loader);
			return static::$_parser;
		}

		// Twig Environment
		$twig_env_conf = \Config::get('parser.View_Twig.environment', array('optimizer' => -1));
		static::$_parser = new Twig_Environment(static::$_parser_loader, $twig_env_conf);

		foreach (\Config::get('parser.View_Twig.extensions') as $ext)
		{
			static::$_parser->addExtension(new $ext());
		}

		// Twig Lexer
		static::$_twig_lexer_conf = \Config::get('parser.View_Twig.delimiters', null);
		if (isset(static::$_twig_lexer_conf))
		{
			isset(static::$_twig_lexer_conf['tag_block'])
				and static::$_twig_lexer_conf['tag_block'] = array_values(static::$_twig_lexer_conf['tag_block']);
			isset(static::$_twig_lexer_conf['tag_comment'])
				and static::$_twig_lexer_conf['tag_comment'] = array_values(static::$_twig_lexer_conf['tag_comment']);
			isset(static::$_twig_lexer_conf['tag_variable'])
				and static::$_twig_lexer_conf['tag_variable'] = array_values(static::$_twig_lexer_conf['tag_variable']);
		}

		return static::$_parser;
	}
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;
    }
974190
public function instance() {
		if ( ! isset( self::$environment ) ) {
			self::$environment = $this->boot();
		}

		return self::$environment;
	}
658408
public static function create() {
		$composer = Composer::getComposerJson( WPEMERGE_CLI_DIR );

		$application = new Application( 'WPEmerge CLI', $composer['version'] );

		$application->add( new AssetsBuild() );
		$application->add( new CreateConfigJson() );
		$application->add( new Install() );
		$application->add( new InstallCarbonFields() );
		$application->add( new InstallCleanComposer() );
		$application->add( new InstallCssFramework() );
		$application->add( new InstallDependencies() );
		$application->add( new InstallFontAwesome() );
		$application->add( new InstallGravityFormsUtilities() );
		$application->add( new InstallHtmlBurgerEnv() );
		$application->add( new InstallPhpTests() );
		$application->add( new MakeController() );
		$application->add( new MakeFacade() );
		$application->add( new MakeViewComposer() );

		return $application;
	}
1286238
public function getInstance()
    {
        if (!$this->parserInstance) {
            /**
             * Check if Twig_Autoloader class exists
             * otherwise include it.
             */
        
            if (!class_exists('\Twig_Autoloader')) {
                require_once $this->parserDirectory . '/Autoloader.php';
            }

            \Twig_Autoloader::register();
            $loader = new \Twig_Loader_Filesystem($this->getTemplateDirs());
            $this->parserInstance = new \Twig_Environment(
                $loader,
                $this->parserOptions
            );

            foreach ($this->parserExtensions as $ext) {
                $extension = is_object($ext) ? $ext : new $ext;
                $this->parserInstance->addExtension($extension);
            }
        }

        return $this->parserInstance;
    }
1007067
public function create()
    {
        $instance = self::createOption($this);
        $this->setId($instance->getId());
        return $instance;
    }
839704
public function create()
    {
        $this->assertPathIsSet();
        $this->assertNotExists();
        $this->doCreate();
        $this->setPermissions();

        return $this;
    }
173347
public function environment()
    {
        $env = $this->getEnv();
        $name = 'Config/Environment/' . ucfirst($env) . '.php';

        foreach ($this->loader->find($name) as $file) {
            require_once $file->getRealPath();
            $class = $file->getClassName();
            $initializer = new $class();
            $initializer->configure($this);
        }
    }
260644
public function create()
    {
        $instance = self::createBrand($this);
        $this->setId($instance->getId());
        return $instance;
    }
442758
public function getTwig() {
		if ($this->twig === null) {
			$options = [];
			if (KEEKO_ENVIRONMENT == KEEKO_DEVELOPMENT) {
				$options['debug'] = true;
			}

			$repo = $this->getResourceRepository();
			$loader = new PuliTemplateLoader($repo);
			$this->twig = new Twig_Environment($loader, $options);

			// puli extension
			$generator = $this->getUrlGenerator();
			$this->twig->addExtension(new PuliExtension($repo, $generator));

			// translator function
			$translator = $this->getTranslator();
			$trans = function($key, $params = [], $domain = null) use ($translator) {
				return $translator->trans($key, $params, $domain);
			};
			$this->twig->addFunction(new Twig_SimpleFunction('t', $trans));

			// firewall
			$firewall = $this->getFirewall();
			$access = function ($module, $action) use ($firewall) {
				return $firewall->hasPermission($module, $action);
			};

			// debug
			if (KEEKO_ENVIRONMENT == KEEKO_DEVELOPMENT) {
				$this->twig->addExtension(new Twig_Extension_Debug());
			}

			$this->twig->addFunction(new Twig_SimpleFunction('can', $access));
		}

		return $this->twig;
	}