Add upstream plugins

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-10-25 22:42:20 +02:00
parent 5d3c2ec184
commit 290736650a
1186 changed files with 302577 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
/**
* Handle finding and parsing a twig template.
*
* @author Time.ly Network Inc.
* @since 2.0
* @instantiator new
* @package AI1EC
* @subpackage AI1EC.Theme.File
*/
class Ai1ec_File_Twig extends Ai1ec_File_Abstract {
/**
* @var Twig_Environment Twig environment for this helper.
*/
protected $_twig;
/**
* @var array
*/
protected $_args;
/**
* @param string $name The name of the template.
* @param array $args The arguments needed to render the template.
* @param Twig_Environment $twig An instance of the Twig environment
*/
public function __construct( $name, array $args, $twig ) {
$this->_args = $args;
$this->_name = $name;
$this->_twig = $twig;
}
/**
* Adds the given search path to the end of the list (low priority).
*
* @param string $search_path Path to add to end of list
*/
public function appendPath( $search_path ) {
$loader = $this->_twig->getLoader();
$loader->addPath( $search_path );
}
/**
* Adds the given search path to the front of the list (high priority).
*
* @param string $search_path Path to add to front of list
*/
public function prepend_path( $search_path ) {
$loader = $this->_twig->getLoader();
$loader->prependPath( $search_path );
}
/* (non-PHPdoc)
* @see Ai1ec_File::locate_file()
*/
public function process_file() {
$loader = $this->_twig->getLoader();
if ( $loader->exists( $this->_name ) ) {
$this->_content = $this->_twig->render( $this->_name, $this->_args );
return true;
}
return false;
}
}