本文整理汇总了PHP中Latte\PhpWriter::formatArray方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWriter::formatArray方法的具体用法?PHP PhpWriter::formatArray怎么用?PHP PhpWriter::formatArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Latte\PhpWriter
的用法示例。
在下文中一共展示了PhpWriter::formatArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: macroControl
/**
* {control name[:method] [params]}
*/
public function macroControl(MacroNode $node, PhpWriter $writer)
{
$words = $node->tokenizer->fetchWords();
if (!$words) {
throw new CompileException('Missing control name in {control}');
}
$name = $writer->formatWord($words[0]);
$method = isset($words[1]) ? ucfirst($words[1]) : '';
$method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
$tokens = $node->tokenizer;
$pos = $tokens->position;
$param = $writer->formatArray();
$tokens->position = $pos;
while ($tokens->nextToken()) {
if ($tokens->isCurrent('=>') && !$tokens->depth) {
$wrap = TRUE;
break;
}
}
if (empty($wrap)) {
$param = substr($param, 1, -1);
// removes array() or []
}
return "/* line {$node->startLine} */ " . ($name[0] === '$' ? "if (is_object({$name})) \$_tmp = {$name}; else " : '') . '$_tmp = $this->global->uiControl->getComponent(' . $name . '); ' . 'if ($_tmp instanceof Nette\\Application\\UI\\IRenderable) $_tmp->redrawControl(NULL, FALSE); ' . ($node->modifiers === '' ? "\$_tmp->{$method}({$param});" : $writer->write("ob_start(function () {}); \$_tmp->{$method}({$param}); echo %modify(ob_get_clean());"));
}
示例2: filter
public function filter(MacroNode $node, PhpWriter $writer)
{
$files = array();
while ($file = $node->tokenizer->fetchWord()) {
$files[] = $this->wwwDir . '/' . ($this->pathResolver ? $this->pathResolver->expandResource($file) : $file);
}
if (!count($files)) {
throw new CompileException('Missing file name in {js}');
}
eval('$args = ' . $writer->formatArray() . ';');
return '$_control[\'js\']->render(\'' . join('\', \'', $files) . '\', array(\'config\' => ' . var_export($args, true) . '));';
}
示例3: macroControl
/**
* {control name[:method] [params]}
*/
public function macroControl(MacroNode $node, PhpWriter $writer)
{
$words = $node->tokenizer->fetchWords();
if (!$words) {
throw new CompileException('Missing control name in {control}');
}
$name = $writer->formatWord($words[0]);
$method = isset($words[1]) ? ucfirst($words[1]) : '';
$method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
$param = $writer->formatArray();
if (!Strings::contains($node->args, '=>')) {
$param = substr($param, $param[0] === '[' ? 1 : 6, -1);
// removes array() or []
}
return ($name[0] === '$' ? "if (is_object({$name})) \$_l->tmp = {$name}; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' . 'if ($_l->tmp instanceof Nette\\Application\\UI\\IRenderable) $_l->tmp->redrawControl(NULL, FALSE); ' . ($node->modifiers === '' ? "\$_l->tmp->{$method}({$param})" : $writer->write("ob_start(); \$_l->tmp->{$method}({$param}); echo %modify(ob_get_clean())"));
}
示例4: wizardStart
/**
* @param MacroNode $node
* @param PhpWriter $writer
* @return string
* @throws CompileException
*/
public function wizardStart(MacroNode $node, PhpWriter $writer)
{
$words = $node->tokenizer->fetchWords();
if (!$words) {
throw new CompileException('Missing control name in {wizard}');
}
$name = $writer->formatWord($words[0]);
$method = isset($words[1]) ? ucfirst($words[1]) : '';
$method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
$param = $writer->formatArray();
if (!Strings::contains($node->args, '=>')) {
$param = substr($param, $param[0] === '[' ? 1 : 6, -1);
// removes array() or []
}
return ($name[0] === '$' ? "if (is_object({$name})) \$_l->tmp = {$name}; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' . 'if (!$_l->tmp instanceof WebChemistry\\Forms\\Controls\\IWizard) throw new \\Exception(\'Wizard must be instance of WebChemistry\\Forms\\Controls\\IWizard\');' . '$wizard = new WebChemistry\\Forms\\Controls\\Wizard\\Facade($_l->tmp);';
}
示例5: macroJs
/**
* {js [:renderType] file[, file2]}
*
* @param \Latte\MacroNode $node
* @param \Latte\PhpWriter $writer
* @return string
* @throws CompileException
*/
public function macroJs(\Latte\MacroNode $node, \Latte\PhpWriter $writer)
{
$words = $node->tokenizer->fetchWords();
if (!$words) {
throw new CompileException("Missing args in {js}");
}
$method = isset($words[1]) ? ucfirst($words[1]) : '';
$method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
if (isset($words[0]) && !isset($words[1])) {
$node->tokenizer->reset();
}
$param = $writer->formatArray();
if (!Strings::contains($node->args, '=>')) {
$param = substr($param, 6, -1);
// removes array()
}
return 'if (($_ctrl=$_control->getComponent("js")) instanceof Nette\\Application\\UI\\IRenderable) $_ctrl->redrawControl(NULL, FALSE); ' . ($node->modifiers === '' ? "\$_ctrl->{$method}({$param})" : $writer->write("ob_start(); \$_ctrl->{$method}({$param}); echo %modify(ob_get_clean())"));
}