43 throw new InvalidArgumentException(sprintf(
'Optimizer mode "%s" is not valid.',
$optimizers));
54 if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
58 if (!version_compare(phpversion(),
'5.4.0RC1',
'>=') && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->
isStrictVariables() && !$env->
hasExtension(
'sandbox')) {
61 if (get_class($node) !==
'Twig_Node') {
62 array_unshift($this->prependedNodes, array());
68 $this->inABody =
true;
82 if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
86 if (self::OPTIMIZE_RAW_FILTER === (self::OPTIMIZE_RAW_FILTER & $this->optimizers)) {
92 if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->
isStrictVariables() && !$env->
hasExtension(
'sandbox')) {
94 $this->inABody =
false;
95 }
elseif ($this->inABody) {
96 if (!$expression && get_class($node) !==
'Twig_Node' &&
$prependedNodes = array_shift($this->prependedNodes)) {
113 if (
'Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
114 $this->prependedNodes[0][] = $node->getAttribute(
'name');
142 $node->getNode(
'expr')->setAttribute(
'output',
true);
144 return $node->getNode(
'expr');
159 return $node->getNode(
'node');
175 $node->setAttribute(
'with_loop',
false);
176 array_unshift($this->loops, $node);
177 }
elseif (!$this->loops) {
202 ||
'parent' === $node->
getNode(
'attribute')->getAttribute(
'value')
204 && (
true === $this->loops[0]->getAttribute(
'with_loop')
206 &&
'loop' === $node->
getNode(
'node')->getAttribute(
'name')
223 array_shift($this->loops);
229 $this->loops[0]->setAttribute(
'with_loop',
true);
234 foreach ($this->loops as $loop) {
235 $loop->setAttribute(
'with_loop',
true);
optimizeRawFilter($node, $env)
Removes "raw" filters.
optimizePrintNode($node, $env)
Optimizes print nodes.
enterOptimizeFor($node, $env)
Optimizes "for" tag by removing the "loop" variable creation whenever possible.
getPriority()
{Returns the priority for this visitor.Priority should be between -10 and 10 (0 is the default)...
Represents an include node.
Represents a node in the AST.
leaveOptimizeFor($node, $env)
Optimizes "for" tag by removing the "loop" variable creation whenever possible.
Represents a block call node.
isStrictVariables()
Checks if the strict_variables option is enabled.
getAttribute($name)
Gets an attribute.
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.
enterNode(Twig_NodeInterface $node, Twig_Environment $env)
{Called before child nodes are visited.The node to visit The Twig environment instanceTwig_NodeInterf...
leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
{Called after child nodes are visited.The node to visit The Twig environment instanceTwig_NodeInterfa...
const OPTIMIZE_RAW_FILTER
Represents a parent node.
__construct($optimizers=-1)
Constructor.
Twig_NodeVisitorInterface is the interface the all node visitor classes must implement.
Represents a node in the AST.
hasExtension($name)
Returns true if the given extension is registered.
Twig_NodeVisitor_Optimizer tries to optimizes the AST.
Stores the Twig configuration.
const OPTIMIZE_VAR_ACCESS
Represents a block call node.
optimizeVariables($node, $env)
getNode($name)
Gets a node by name.
Represents a node that outputs an expression.