first commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use WPML\Core\Twig_Environment;
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_Twig_Template implements IWPML_Template_Service {
|
||||
private $twig;
|
||||
|
||||
/**
|
||||
* WPML_Twig_Template constructor.
|
||||
*
|
||||
* @param Twig_Environment $twig
|
||||
*/
|
||||
public function __construct( Twig_Environment $twig ) {
|
||||
$this->twig = $twig;
|
||||
}
|
||||
|
||||
public function show( $model, $template ) {
|
||||
return $this->twig->render( $template, $model );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
interface IWPML_Template_Service {
|
||||
public function show( $model, $template );
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use WPML\Core\Twig_Loader_Filesystem;
|
||||
use WPML\Core\Twig_Environment;
|
||||
|
||||
/**
|
||||
* Class WPML_Twig_Template_Loader
|
||||
*/
|
||||
class WPML_Twig_Template_Loader {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $paths;
|
||||
|
||||
/**
|
||||
* WPML_Twig_Template_Loader constructor.
|
||||
*
|
||||
* @param array $paths
|
||||
*/
|
||||
public function __construct( array $paths ) {
|
||||
$this->paths = $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WPML_Twig_Template
|
||||
*/
|
||||
public function get_template() {
|
||||
$twig_loader = new Twig_Loader_Filesystem( $this->paths );
|
||||
$environment_args = array();
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
$environment_args['debug'] = true;
|
||||
}
|
||||
$twig = new Twig_Environment( $twig_loader, $environment_args );
|
||||
return new WPML_Twig_Template( $twig );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user