for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Rocket\UI\Forms\Support\Twig;
use Twig_Compiler;
use Twig_Node;
/**
* Form extension for twig
*/
*
* @author Stéphane Goetz
class Node extends Twig_Node
{
* Form parameters
* @var array
private $_parameters;
* Form methods
private $_methods;
* {@inheritdoc}
public function __construct(array $parameters = [], array $methods = [], $lineno = 0, $tag = null)
$this->_parameters = $parameters;
$this->_methods = $methods;
parent::__construct([new Twig_Node()], [], $lineno, $tag);
}
* Compiles the node to PHP.
* @param Twig_Compiler $compiler A Twig_Compiler instance
public function compile(Twig_Compiler $compiler)
$compiler->addDebugInfo($this);
$compiler->write('echo \Rocket\UI\Forms\Forms::field(');
$first = true;
foreach ($this->_parameters as $param) {
if ($first) {
$first = false;
} else {
$compiler->raw(',');
$compiler->subcompile($param);
$compiler->raw(')');
foreach ($this->_methods as $methods) {
foreach ($methods as $method => $parameters) {
$compiler->raw('->' . $method . '(');
foreach ($parameters as $param) {
$compiler->raw('->render();');