本文整理汇总了PHP中Twig_Node::hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Node::hasAttribute方法的具体用法?PHP Twig_Node::hasAttribute怎么用?PHP Twig_Node::hasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Node
的用法示例。
在下文中一共展示了Twig_Node::hasAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadNode
/**
* Loads assets from the supplied node.
*
* @param \Twig_Node $node
*
* @return array An array of asset formulae indexed by name
*/
private function loadNode(\Twig_Node $node)
{
$formulae = array();
if ($node instanceof AsseticNode) {
$formulae[$node->getAttribute('name')] = array($node->getAttribute('inputs'), $node->getAttribute('filters'), array('output' => $node->getAttribute('asset')->getTargetPath(), 'name' => $node->getAttribute('name'), 'debug' => $node->getAttribute('debug'), 'combine' => $node->getAttribute('combine'), 'vars' => $node->getAttribute('vars')));
} elseif ($node instanceof \Twig_Node_Expression_Function) {
$name = version_compare(\Twig_Environment::VERSION, '1.2.0-DEV', '<') ? $node->getNode('name')->getAttribute('name') : $node->getAttribute('name');
if ($this->twig->getFunction($name) instanceof AsseticFilterFunction) {
$arguments = array();
foreach ($node->getNode('arguments') as $argument) {
$arguments[] = eval('return ' . $this->twig->compile($argument) . ';');
}
$invoker = $this->twig->getExtension('assetic')->getFilterInvoker($name);
$inputs = isset($arguments[0]) ? (array) $arguments[0] : array();
$filters = $invoker->getFilters();
$options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array());
if (!isset($options['name'])) {
$options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options);
}
$formulae[$options['name']] = array($inputs, $filters, $options);
}
}
foreach ($node as $child) {
if ($child instanceof \Twig_Node) {
$formulae += $this->loadNode($child);
}
}
if ($node->hasAttribute('embedded_templates')) {
foreach ($node->getAttribute('embedded_templates') as $child) {
$formulae += $this->loadNode($child);
}
}
return $formulae;
}
示例2: loadNode
/**
* Loads assets from the supplied node.
*
* @param \Twig_Node $node
*
* @return array An array of asset formulae indexed by name
*/
private function loadNode(\Twig_Node $node)
{
$formulae = array();
if ($node instanceof AsseticNode) {
$formulae[$node->getAttribute('name')] = array($node->getAttribute('inputs'), $node->getAttribute('filters'), array('output' => $node->getAttribute('asset')->getTargetPath(), 'name' => $node->getAttribute('name'), 'debug' => $node->getAttribute('debug'), 'combine' => $node->getAttribute('combine'), 'vars' => $node->getAttribute('vars')));
} elseif ($node instanceof \Twig_Node_Expression_Function) {
$name = $node->getAttribute('name');
if ($this->twig->getFunction($name) instanceof AsseticFilterFunction) {
$arguments = array();
foreach ($node->getNode('arguments') as $argument) {
$arguments[] = eval('return ' . $this->twig->compile($argument) . ';');
}
$invoker = $this->twig->getExtension('assetic')->getFilterInvoker($name);
$inputs = isset($arguments[0]) ? (array) $arguments[0] : array();
$filters = $invoker->getFilters();
$options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array());
if (!isset($options['name'])) {
$options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options);
}
$formulae[$options['name']] = array($inputs, $filters, $options);
}
}
foreach ($node as $child) {
if ($child instanceof \Twig_Node) {
$formulae += $this->loadNode($child);
}
}
if ($node->hasAttribute('embedded_templates')) {
foreach ($node->getAttribute('embedded_templates') as $child) {
$formulae += $this->loadNode($child);
}
}
$formulaes = array();
$asseticDebug = $this->app['assetic.debug'];
foreach ($formulae as $n => $f) {
list($inputs, $filters, $options) = $f;
// 當沒有資源或此資源已被解開過的時候
if (count($inputs) > 0 && strlen($n) <= 7 && ($asseticDebug == true || $options['debug'] === true || $options['combine'] === false)) {
$path = pathinfo($options['output']);
$counter = 1;
foreach ($inputs as $input) {
$inputPath = pathinfo($input);
$_name = $n . '_' . md5($input);
$_inputs = array($input);
$_filters = $filters;
$_options = array('output' => "{$path['dirname']}/{$path['filename']}_{$inputPath['filename']}_{$counter}.{$path['extension']}", 'name' => "{$path['filename']}_{$inputPath['filename']}_{$counter}") + $options;
$formulaes[$_name] = array($_inputs, $_filters, $_options);
$counter++;
}
} else {
$formulaes[$n] = $f;
}
}
$formulae = $formulaes;
return $formulae;
}
开发者ID:wake,项目名称:twig-assetic-integration-provider,代码行数:63,代码来源:TwigAsseticIntegrationFormulaLoader.php
示例3: getAttribute
/**
* @param \Twig_Node $node
* @param $name
* @return mixed|null
*/
public function getAttribute(\Twig_Node $node, $name)
{
return $node->hasAttribute($name) ? $node->getAttribute($name) : null;
}