本文整理汇总了PHP中Twig_NodeInterface::getNodeTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_NodeInterface::getNodeTag方法的具体用法?PHP Twig_NodeInterface::getNodeTag怎么用?PHP Twig_NodeInterface::getNodeTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_NodeInterface
的用法示例。
在下文中一共展示了Twig_NodeInterface::getNodeTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enterNode
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
{
if ($node instanceof Twig_Node_Module) {
$this->inAModule = true;
$this->tags = array();
$this->filters = array();
return $node;
} elseif ($this->inAModule) {
// look for tags
if ($node->getNodeTag()) {
$this->tags[$node->getNodeTag()] = true;
}
// look for filters
if ($node instanceof Twig_Node_Expression_Filter) {
foreach ($node->getFilters() as $filter) {
$this->filters[$filter[0]] = true;
}
}
// look for simple print statement ({{ article }})
if ($node instanceof Twig_Node_Print && $node->getExpression() instanceof Twig_Node_Expression_Name) {
return new Twig_Node_SandboxPrint($node->getExpression(), $node->getLine(), $node->getNodeTag());
}
}
return $node;
}
示例2: enterNode
/**
* Called before child nodes are visited.
*
* @param Twig_NodeInterface $node The node to visit
* @param Twig_Environment $env The Twig environment instance
*
* @return Twig_NodeInterface The modified node
*/
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
{
if ($node instanceof Twig_Node_Module) {
$this->inAModule = true;
$this->tags = array();
$this->filters = array();
$this->functions = array();
return $node;
} elseif ($this->inAModule) {
// look for tags
if ($node->getNodeTag() && !isset($this->tags[$node->getNodeTag()])) {
$this->tags[$node->getNodeTag()] = $node;
}
// look for filters
if ($node instanceof Twig_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) {
$this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
}
// look for functions
if ($node instanceof Twig_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) {
$this->functions[$node->getAttribute('name')] = $node;
}
// wrap print to check __toString() calls
if ($node instanceof Twig_Node_Print) {
return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getLine(), $node->getNodeTag());
}
}
return $node;
}
示例3: enterNode
/**
* Called before child nodes are visited.
*
* @param Twig_NodeInterface $node The node to visit
* @param Twig_Environment $env The Twig environment instance
*
* @param Twig_NodeInterface The modified node
*/
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
{
if ($node instanceof Twig_Node_Module) {
$this->inAModule = true;
$this->tags = array();
$this->filters = array();
return $node;
} elseif ($this->inAModule) {
// look for tags
if ($node->getNodeTag()) {
$this->tags[] = $node->getNodeTag();
}
// look for filters
if ($node instanceof Twig_Node_Expression_Filter) {
for ($i = 0; $i < count($node->getNode('filters')); $i += 2) {
$this->filters[] = $node->getNode('filters')->getNode($i)->getAttribute('value');
}
}
// look for simple print statements ({{ article }})
if ($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_Name) {
return new Twig_Node_SandboxedPrint($node);
}
}
return $node;
}
示例4: optimizeRenderBlock
/**
* Replaces "echo $this->renderBlock()" with "$this->displayBlock()".
*
* @param Twig_NodeInterface $node A Node
* @param Twig_Environment $env The current Twig environment
*/
protected function optimizeRenderBlock($node, $env)
{
if ($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_BlockReference) {
return new Twig_Node_BlockReference($node->getNode('expr')->getNode('name')->getAttribute('value'), $node->getLine(), $node->getNodeTag());
}
return $node;
}
示例5: enterNode
/**
* Defined by Twig_NodeVisitorInterface
*
* Extracts messages from calls to the translate function.
*/
public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
{
if ($node instanceof \Skeleton\I18n\Template\Twig\Extension\Node\Trans\Tigron) {
if ($node->getNodeTag() == 'trans') {
$this->extracted[] = $node->getNode('body')->getAttribute('value');
}
} elseif ($node instanceof \Twig_Node_Print) {
$n = $node->getNode('expr');
while ($n instanceof \Twig_Node_Expression_Filter) {
$filter = null;
if ($n->hasNode('filter')) {
$filter = $n->getNode('filter')->getAttribute('value');
}
$n = $n->getNode('node');
if ($n instanceof \Twig_Node_Expression_Constant and $filter == 'trans') {
$this->extracted[] = $n->getAttribute('value');
}
}
} elseif ($node instanceof \Twig_Node_Expression_Array) {
$data = $node->getIterator();
foreach ($data as $row) {
if ($row instanceof \Twig_Node_Expression_Filter) {
if ($row->hasNode('filter') and $row->getNode('filter')->getAttribute('value') == 'trans') {
$this->extracted[] = $row->getNode('node')->getAttribute('value');
}
}
}
}
return $node;
}
示例6: enterNode
/**
* Called before child nodes are visited.
*
* @param Twig_NodeInterface $node The node to visit
* @param Twig_Environment $env The Twig environment instance
*
* @return Twig_NodeInterface The modified node
*/
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
{
// in a sandbox tag, only include tags are allowed
if ($node instanceof Twig_Node_Sandbox && !$node->getNode('body') instanceof Twig_Node_Include) {
foreach ($node->getNode('body') as $n) {
if ($n instanceof Twig_Node_Text && ctype_space($n->getAttribute('data'))) {
continue;
}
if (!$n instanceof Twig_Node_Include) {
throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $n->getLine());
}
}
}
if ($node instanceof Twig_Node_Module) {
$this->inAModule = true;
$this->tags = array();
$this->filters = array();
$this->functions = array();
return $node;
} elseif ($this->inAModule) {
// look for tags
if ($node->getNodeTag()) {
$this->tags[] = $node->getNodeTag();
}
// look for filters
if ($node instanceof Twig_Node_Expression_Filter) {
$this->filters[] = $node->getNode('filter')->getAttribute('value');
}
// look for functions
if ($node instanceof Twig_Node_Expression_Function) {
$this->functions[] = $node->getAttribute('name');
}
// wrap print to check __toString() calls
if ($node instanceof Twig_Node_Print) {
return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getLine(), $node->getNodeTag());
}
}
return $node;
}