17 $closingParenthesis =
false;
19 if (is_string($callable)) {
20 $compiler->
raw($callable);
22 $compiler->
raw(sprintf(
'$this->env->getExtension(\'%s\')->%s', $callable[0]->getName(), $callable[1]));
25 $compiler->
raw(sprintf(
'call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->
getAttribute(
'name')));
26 $closingParenthesis =
true;
34 if ($closingParenthesis) {
46 $compiler->
raw(
'$this->env');
54 $compiler->
raw(
'$context');
59 foreach ($this->
getAttribute(
'arguments') as $argument) {
63 $compiler->
string($argument);
76 if ($this->
hasNode(
'arguments') && null !== $this->
getNode(
'arguments')) {
81 foreach ($arguments as $node) {
95 $parameters = array();
97 foreach ($arguments as $name => $node) {
105 $parameters[$name] = $node;
113 throw new LogicException(sprintf(
'Named arguments are not supported for %s "%s".', $this->
getAttribute(
'type'), $this->
getAttribute(
'name')));
117 if (is_array($callable)) {
118 $r =
new ReflectionMethod($callable[0], $callable[1]);
119 }
elseif (is_object($callable) && !$callable instanceof Closure) {
120 $r =
new ReflectionObject($callable);
121 $r = $r->getMethod(
'__invoke');
123 $r =
new ReflectionFunction($callable);
126 $definition = $r->getParameters();
128 array_shift($definition);
131 array_shift($definition);
134 array_shift($definition);
137 foreach ($this->
getAttribute(
'arguments') as $argument) {
138 array_shift($definition);
142 $arguments = array();
144 foreach ($definition as $param) {
147 if (array_key_exists($name, $parameters)) {
148 if (array_key_exists($pos, $parameters)) {
152 $arguments[] = $parameters[$name];
153 unset($parameters[$name]);
154 }
elseif (array_key_exists($pos, $parameters)) {
155 $arguments[] = $parameters[$pos];
156 unset($parameters[$pos]);
158 }
elseif ($param->isDefaultValueAvailable()) {
160 }
elseif ($param->isOptional()) {
167 if (!empty($parameters)) {
176 return strtolower(preg_replace(array(
'/([A-Z]+)([A-Z][a-z])/',
'/([a-z\d])([A-Z])/'), array(
'\\1_\\2',
'\\1_\\2'), $name));
hasNode($name)
Returns true if the node with the given identifier exists.
Compiles a node to PHP code.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
getAttribute($name)
Gets an attribute.
hasAttribute($name)
Returns true if the attribute is defined.
compileCallable(Twig_Compiler $compiler)
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Abstract class for all nodes that represents an expression.
getArguments($callable, $arguments)
string($value)
Adds a quoted string to the compiled code.
subcompile(Twig_NodeInterface $node, $raw=true)
Interface implemented by extension classes.
raw($string)
Adds a raw string to the compiled code.
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
compileArguments(Twig_Compiler $compiler)
getNode($name)
Gets a node by name.