for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/* @description Transformation Style Sheets - Revolutionising PHP templating *
* @author Tom Butler [email protected] *
* @copyright 2017 Tom Butler <[email protected]> | https://r.je/ *
* @license http://www.opensource.org/licenses/bsd-license.php BSD License *
* @version 1.2 */
namespace Transphporm\TSSFunction;
/* Handles data() and iteration() function calls from the stylesheet */
class Data implements \Transphporm\TSSFunction{
private $data;
private $dataKey;
private $functionSet;
public function __construct(\Transphporm\Hook\ElementData $data, \Transphporm\FunctionSet $functionSet, $dataKey = 'data') {
$this->data = $data;
$this->dataKey = $dataKey;
$this->functionSet = $functionSet;
}
public function run(array $args, \DomElement $element = null) {
if ($this->dataKey === "root") $data = $this->data->getData(null, 'data');
else $data = $this->data->getData($element, $this->dataKey);
$parser = new \Transphporm\Parser\Value($this->functionSet, true, true);
$return = $parser->parseTokens(new \Transphporm\Parser\Tokens($args), $data);
return $return[0];