Ajout du FR
Ajout du FR + correction du "functions.php"
This commit is contained in:
90
vendor/symfony/twig-bridge/Node/DumpNode.php
vendored
Normal file
90
vendor/symfony/twig-bridge/Node/DumpNode.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
* @author Julien Galenski <julien.galenski@gmail.com>
|
||||
*/
|
||||
class DumpNode extends Node
|
||||
{
|
||||
private $varPrefix;
|
||||
|
||||
public function __construct($varPrefix, Node $values = null, $lineno, $tag = null)
|
||||
{
|
||||
$nodes = array();
|
||||
if (null !== $values) {
|
||||
$nodes['values'] = $values;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array(), $lineno, $tag);
|
||||
$this->varPrefix = $varPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->write("if (\$this->env->isDebug()) {\n")
|
||||
->indent();
|
||||
|
||||
if (!$this->hasNode('values')) {
|
||||
// remove embedded templates (macros) from the context
|
||||
$compiler
|
||||
->write(sprintf('$%svars = array();'."\n", $this->varPrefix))
|
||||
->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix))
|
||||
->indent()
|
||||
->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix))
|
||||
->indent()
|
||||
->write(sprintf('$%1$svars[$%1$skey] = $%1$sval;'."\n", $this->varPrefix))
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
->addDebugInfo($this)
|
||||
->write(sprintf('\Symfony\Component\VarDumper\VarDumper::dump($%svars);'."\n", $this->varPrefix));
|
||||
} elseif (($values = $this->getNode('values')) && 1 === $values->count()) {
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write('\Symfony\Component\VarDumper\VarDumper::dump(')
|
||||
->subcompile($values->getNode(0))
|
||||
->raw(");\n");
|
||||
} else {
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write('\Symfony\Component\VarDumper\VarDumper::dump(array('."\n")
|
||||
->indent();
|
||||
foreach ($values as $node) {
|
||||
$compiler->write('');
|
||||
if ($node->hasAttribute('name')) {
|
||||
$compiler
|
||||
->string($node->getAttribute('name'))
|
||||
->raw(' => ');
|
||||
}
|
||||
$compiler
|
||||
->subcompile($node)
|
||||
->raw(",\n");
|
||||
}
|
||||
$compiler
|
||||
->outdent()
|
||||
->write("));\n");
|
||||
}
|
||||
|
||||
$compiler
|
||||
->outdent()
|
||||
->write("}\n");
|
||||
}
|
||||
}
|
||||
21
vendor/symfony/twig-bridge/Node/FormEnctypeNode.php
vendored
Normal file
21
vendor/symfony/twig-bridge/Node/FormEnctypeNode.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use the helper "form_start()" instead.
|
||||
*/
|
||||
class FormEnctypeNode extends SearchAndRenderBlockNode
|
||||
{
|
||||
}
|
||||
37
vendor/symfony/twig-bridge/Node/FormThemeNode.php
vendored
Normal file
37
vendor/symfony/twig-bridge/Node/FormThemeNode.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FormThemeNode extends Node
|
||||
{
|
||||
public function __construct(Node $form, Node $resources, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('form' => $form, 'resources' => $resources), array(), $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write('$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->setTheme(')
|
||||
->subcompile($this->getNode('form'))
|
||||
->raw(', ')
|
||||
->subcompile($this->getNode('resources'))
|
||||
->raw(");\n");
|
||||
}
|
||||
}
|
||||
45
vendor/symfony/twig-bridge/Node/RenderBlockNode.php
vendored
Normal file
45
vendor/symfony/twig-bridge/Node/RenderBlockNode.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Expression\FunctionExpression;
|
||||
|
||||
/**
|
||||
* Compiles a call to {@link \Symfony\Component\Form\FormRendererInterface::renderBlock()}.
|
||||
*
|
||||
* The function name is used as block name. For example, if the function name
|
||||
* is "foo", the block "foo" will be rendered.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class RenderBlockNode extends FunctionExpression
|
||||
{
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
$arguments = iterator_to_array($this->getNode('arguments'));
|
||||
$compiler->write('$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->renderBlock(');
|
||||
|
||||
if (isset($arguments[0])) {
|
||||
$compiler->subcompile($arguments[0]);
|
||||
$compiler->raw(', \''.$this->getAttribute('name').'\'');
|
||||
|
||||
if (isset($arguments[1])) {
|
||||
$compiler->raw(', ');
|
||||
$compiler->subcompile($arguments[1]);
|
||||
}
|
||||
}
|
||||
|
||||
$compiler->raw(')');
|
||||
}
|
||||
}
|
||||
111
vendor/symfony/twig-bridge/Node/SearchAndRenderBlockNode.php
vendored
Normal file
111
vendor/symfony/twig-bridge/Node/SearchAndRenderBlockNode.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\FunctionExpression;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class SearchAndRenderBlockNode extends FunctionExpression
|
||||
{
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
$compiler->raw('$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(');
|
||||
|
||||
preg_match('/_([^_]+)$/', $this->getAttribute('name'), $matches);
|
||||
|
||||
$label = null;
|
||||
$arguments = iterator_to_array($this->getNode('arguments'));
|
||||
$blockNameSuffix = $matches[1];
|
||||
|
||||
if (isset($arguments[0])) {
|
||||
$compiler->subcompile($arguments[0]);
|
||||
$compiler->raw(', \''.$blockNameSuffix.'\'');
|
||||
|
||||
if (isset($arguments[1])) {
|
||||
if ('label' === $blockNameSuffix) {
|
||||
// The "label" function expects the label in the second and
|
||||
// the variables in the third argument
|
||||
$label = $arguments[1];
|
||||
$variables = isset($arguments[2]) ? $arguments[2] : null;
|
||||
$lineno = $label->getTemplateLine();
|
||||
|
||||
if ($label instanceof ConstantExpression) {
|
||||
// If the label argument is given as a constant, we can either
|
||||
// strip it away if it is empty, or integrate it into the array
|
||||
// of variables at compile time.
|
||||
$labelIsExpression = false;
|
||||
|
||||
// Only insert the label into the array if it is not empty
|
||||
if (!twig_test_empty($label->getAttribute('value'))) {
|
||||
$originalVariables = $variables;
|
||||
$variables = new ArrayExpression(array(), $lineno);
|
||||
$labelKey = new ConstantExpression('label', $lineno);
|
||||
|
||||
if (null !== $originalVariables) {
|
||||
foreach ($originalVariables->getKeyValuePairs() as $pair) {
|
||||
// Don't copy the original label attribute over if it exists
|
||||
if ((string) $labelKey !== (string) $pair['key']) {
|
||||
$variables->addElement($pair['value'], $pair['key']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert the label argument into the array
|
||||
$variables->addElement($label, $labelKey);
|
||||
}
|
||||
} else {
|
||||
// The label argument is not a constant, but some kind of
|
||||
// expression. This expression needs to be evaluated at runtime.
|
||||
// Depending on the result (whether it is null or not), the
|
||||
// label in the arguments should take precedence over the label
|
||||
// in the attributes or not.
|
||||
$labelIsExpression = true;
|
||||
}
|
||||
} else {
|
||||
// All other functions than "label" expect the variables
|
||||
// in the second argument
|
||||
$label = null;
|
||||
$variables = $arguments[1];
|
||||
$labelIsExpression = false;
|
||||
}
|
||||
|
||||
if (null !== $variables || $labelIsExpression) {
|
||||
$compiler->raw(', ');
|
||||
|
||||
if (null !== $variables) {
|
||||
$compiler->subcompile($variables);
|
||||
}
|
||||
|
||||
if ($labelIsExpression) {
|
||||
if (null !== $variables) {
|
||||
$compiler->raw(' + ');
|
||||
}
|
||||
|
||||
// Check at runtime whether the label is empty.
|
||||
// If not, add it to the array at runtime.
|
||||
$compiler->raw('(twig_test_empty($_label_ = ');
|
||||
$compiler->subcompile($label);
|
||||
$compiler->raw(') ? array() : array("label" => $_label_))');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$compiler->raw(')');
|
||||
}
|
||||
}
|
||||
48
vendor/symfony/twig-bridge/Node/StopwatchNode.php
vendored
Normal file
48
vendor/symfony/twig-bridge/Node/StopwatchNode.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Expression\AssignNameExpression;
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
* Represents a stopwatch node.
|
||||
*
|
||||
* @author Wouter J <wouter@wouterj.nl>
|
||||
*/
|
||||
class StopwatchNode extends Node
|
||||
{
|
||||
public function __construct(Node $name, Node $body, AssignNameExpression $var, $lineno = 0, $tag = null)
|
||||
{
|
||||
parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write('')
|
||||
->subcompile($this->getNode('var'))
|
||||
->raw(' = ')
|
||||
->subcompile($this->getNode('name'))
|
||||
->write(";\n")
|
||||
->write("\$this->env->getExtension('Symfony\Bridge\Twig\Extension\StopwatchExtension')->getStopwatch()->start(")
|
||||
->subcompile($this->getNode('var'))
|
||||
->raw(", 'template');\n")
|
||||
->subcompile($this->getNode('body'))
|
||||
->write("\$this->env->getExtension('Symfony\Bridge\Twig\Extension\StopwatchExtension')->getStopwatch()->stop(")
|
||||
->subcompile($this->getNode('var'))
|
||||
->raw(");\n")
|
||||
;
|
||||
}
|
||||
}
|
||||
32
vendor/symfony/twig-bridge/Node/TransDefaultDomainNode.php
vendored
Normal file
32
vendor/symfony/twig-bridge/Node/TransDefaultDomainNode.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Expression\AbstractExpression;
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class TransDefaultDomainNode extends Node
|
||||
{
|
||||
public function __construct(AbstractExpression $expr, $lineno = 0, $tag = null)
|
||||
{
|
||||
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
// noop as this node is just a marker for TranslationDefaultDomainNodeVisitor
|
||||
}
|
||||
}
|
||||
132
vendor/symfony/twig-bridge/Node/TransNode.php
vendored
Normal file
132
vendor/symfony/twig-bridge/Node/TransNode.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Expression\AbstractExpression;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\TextNode;
|
||||
|
||||
// BC/FC with namespaced Twig
|
||||
class_exists('Twig\Node\Expression\ArrayExpression');
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class TransNode extends Node
|
||||
{
|
||||
public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, $lineno = 0, $tag = null)
|
||||
{
|
||||
$nodes = array('body' => $body);
|
||||
if (null !== $domain) {
|
||||
$nodes['domain'] = $domain;
|
||||
}
|
||||
if (null !== $count) {
|
||||
$nodes['count'] = $count;
|
||||
}
|
||||
if (null !== $vars) {
|
||||
$nodes['vars'] = $vars;
|
||||
}
|
||||
if (null !== $locale) {
|
||||
$nodes['locale'] = $locale;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array(), $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$defaults = new ArrayExpression(array(), -1);
|
||||
if ($this->hasNode('vars') && ($vars = $this->getNode('vars')) instanceof ArrayExpression) {
|
||||
$defaults = $this->getNode('vars');
|
||||
$vars = null;
|
||||
}
|
||||
list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
|
||||
|
||||
$method = !$this->hasNode('count') ? 'trans' : 'transChoice';
|
||||
|
||||
$compiler
|
||||
->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->'.$method.'(')
|
||||
->subcompile($msg)
|
||||
;
|
||||
|
||||
$compiler->raw(', ');
|
||||
|
||||
if ($this->hasNode('count')) {
|
||||
$compiler
|
||||
->subcompile($this->getNode('count'))
|
||||
->raw(', ')
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $vars) {
|
||||
$compiler
|
||||
->raw('array_merge(')
|
||||
->subcompile($defaults)
|
||||
->raw(', ')
|
||||
->subcompile($this->getNode('vars'))
|
||||
->raw(')')
|
||||
;
|
||||
} else {
|
||||
$compiler->subcompile($defaults);
|
||||
}
|
||||
|
||||
$compiler->raw(', ');
|
||||
|
||||
if (!$this->hasNode('domain')) {
|
||||
$compiler->repr('messages');
|
||||
} else {
|
||||
$compiler->subcompile($this->getNode('domain'));
|
||||
}
|
||||
|
||||
if ($this->hasNode('locale')) {
|
||||
$compiler
|
||||
->raw(', ')
|
||||
->subcompile($this->getNode('locale'))
|
||||
;
|
||||
}
|
||||
$compiler->raw(");\n");
|
||||
}
|
||||
|
||||
protected function compileString(Node $body, ArrayExpression $vars, $ignoreStrictCheck = false)
|
||||
{
|
||||
if ($body instanceof ConstantExpression) {
|
||||
$msg = $body->getAttribute('value');
|
||||
} elseif ($body instanceof TextNode) {
|
||||
$msg = $body->getAttribute('data');
|
||||
} else {
|
||||
return array($body, $vars);
|
||||
}
|
||||
|
||||
preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
|
||||
|
||||
foreach ($matches[1] as $var) {
|
||||
$key = new ConstantExpression('%'.$var.'%', $body->getTemplateLine());
|
||||
if (!$vars->hasElement($key)) {
|
||||
if ('count' === $var && $this->hasNode('count')) {
|
||||
$vars->addElement($this->getNode('count'), $key);
|
||||
} else {
|
||||
$varExpr = new NameExpression($var, $body->getTemplateLine());
|
||||
$varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
|
||||
$vars->addElement($varExpr, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(new ConstantExpression(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user