当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpWriter::formatArray方法代码示例

本文整理汇总了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());"));
 }
开发者ID:hrach,项目名称:nette-application,代码行数:28,代码来源:UIMacros.php

示例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) . '));';
 }
开发者ID:venne,项目名称:assets,代码行数:12,代码来源:JsMacro.php

示例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())"));
 }
开发者ID:vol0054,项目名称:vizitky,代码行数:19,代码来源:UIMacros.php

示例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);';
 }
开发者ID:webchemistry,项目名称:forms-wizard,代码行数:22,代码来源:Macros.php

示例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())"));
 }
开发者ID:lohini,项目名称:webloader,代码行数:26,代码来源:UIMacros.php


注:本文中的Latte\PhpWriter::formatArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。