當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。