HEX
HEX
Server: Apache
System: Linux localhost.localdomain 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User: www (1001)
PHP: 8.1.32
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/ahmsolaiman.com/wp-content/plugins/types/application/models/helper/twig.php
<?php

use OTGS\Toolset\Twig\Environment;

/**
 * @since 2.0
 */
class Types_Helper_Twig implements Types_Interface_Template {

	/**
	 * @var Environment
	 */
	private $twig;

	/** @noinspection PhpDocMissingThrowsInspection */
	/**
	 * Types_Helper_Twig constructor.
	 *
	 * @param string[] $additional_namespaces Twig namespaces to add, "namespace => absolute path" value pairs.
	 * @param Toolset_Common_Bootstrap|null $toolset_common_bootstrap_di
	 * @param Toolset_Gui_Base|null $toolset_gui_base_di
	 *
	 * @since m2m Implemented possibility to add other Twig namespaces.
	 */
	public function __construct(
		array $additional_namespaces = array(),
		Toolset_Common_Bootstrap $toolset_common_bootstrap_di = null,
		Toolset_Gui_Base $toolset_gui_base_di = null
	) {

		// Ensure that we have Twig ready
		$tcb = ( null === $toolset_common_bootstrap_di ? Toolset_Common_Bootstrap::get_instance()
			: $toolset_common_bootstrap_di );
		$tcb->register_gui_base();

		$gui_base = ( null === $toolset_gui_base_di ? Toolset_Gui_Base::get_instance() : $toolset_gui_base_di );
		$gui_base->init();

		$namespaces = array_merge( array( 'types' => TYPES_ABSPATH . '/application/views' ), $additional_namespaces );

		/** @noinspection PhpUnhandledExceptionInspection */
		$this->twig = $gui_base->create_twig_environment( $namespaces );
	}


	public function render( $file, $data ) {
		/** @noinspection PhpUnhandledExceptionInspection */
		return $this->twig->render( "@types$file", $data );
	}


	/**
	 * Return the underlying Twig environment.
	 *
	 * @since m2m
	 */
	public function get_environment() {
		return $this->twig;
	}


	/**
	 * Alias for Toolset_Twig_Dialog_Box::construct()
	 *
	 * @param string $id
	 * @param string $template_path
	 * @param array $template_values
	 */
	public function prepare_dialog( $id, $template_path, $template_values = array() ) {
		$twig_factory = new Toolset_Twig_Dialog_Box_Factory();

		$twig_factory->create(
			$id,
			$this->twig,
			$template_values,
			"@types$template_path"
		);
	}
}