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


PHP PhpWriter::using方法代码示例

本文整理汇总了PHP中Latte\PhpWriter::using方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWriter::using方法的具体用法?PHP PhpWriter::using怎么用?PHP PhpWriter::using使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Latte\PhpWriter的用法示例。


在下文中一共展示了PhpWriter::using方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nodeOpened

 /**
  * New node is found. Returns FALSE to reject.
  *
  * @param MacroNode $node
  * @return bool
  * @throws Latte\CompileException
  */
 public function nodeOpened(MacroNode $node)
 {
     if ($node->prefix) {
         return false;
     }
     if ($node->modifiers) {
         throw new Latte\CompileException("Modifiers are not allowed in {{$node->name}}.");
     }
     $file = $node->tokenizer->fetchWord();
     if ($file === false) {
         throw new Latte\CompileException("Missing file name in {{$node->name}}.");
     } elseif ($node->tokenizer->fetchWord()) {
         throw new Latte\CompileException("Multiple arguments are not supported in {{$node->name}}.");
     }
     $node->isEmpty = true;
     $node->modifiers = '|safeurl|escape';
     // auto-escape
     $writer = Latte\PhpWriter::using($node, $this->compiler);
     if ($this->debugMode) {
         $node->openingCode = $writer->write('<?php echo %modify(%1.word . \'?\' . Nepada\\BustCache\\Helpers::timestamp(%0.var . %1.word)) ?>', $this->wwwDir, $file);
     } elseif (preg_match('#^(["\']?)[^$\'"]*\\1$#', $file)) {
         // Static path
         $file = trim($file, '"\'');
         $url = $file . '?' . Helpers::hash($this->wwwDir . $file);
         $url = Latte\Runtime\Filters::safeUrl($url);
         $node->openingCode = $writer->write('<?php echo %escape(%var) ?>', $url);
     } else {
         $node->openingCode = $writer->write('<?php echo %modify(%1.word . \'?\' . Nepada\\BustCache\\Helpers::hash(%0.var . %1.word)) ?>', $this->wwwDir, $file);
     }
 }
开发者ID:nepada,项目名称:bust-cache,代码行数:37,代码来源:BustCacheMacro.php

示例2: nodeOpened

 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(Latte\MacroNode $node)
 {
     if ($node->modifiers) {
         trigger_error("Modifiers are not allowed in {{$node->name}}", E_USER_WARNING);
     }
     $this->used = TRUE;
     $node->isEmpty = FALSE;
     $node->openingCode = Latte\PhpWriter::using($node)->write('<?php if (Nette\\Bridges\\CacheLatte\\CacheMacro::createCache($netteCacheStorage, %var, $_g->caches, %node.array?)) { ?>', Nette\Utils\Random::generate());
 }
开发者ID:4iz278,项目名称:cviceni,代码行数:13,代码来源:CacheMacro.php

示例3: nodeOpened

 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(Latte\MacroNode $node)
 {
     if ($node->modifiers) {
         throw new Latte\CompileException('Modifiers are not allowed in ' . $node->getNotation());
     }
     $this->used = TRUE;
     $node->empty = FALSE;
     $node->openingCode = Latte\PhpWriter::using($node)->write('<?php if (Nette\\Bridges\\CacheLatte\\CacheMacro::createCache($this->global->cacheStorage, %var, $this->global->cacheStack, %node.array?)) { ?>', Nette\Utils\Random::generate());
 }
开发者ID:nette,项目名称:caching,代码行数:13,代码来源:CacheMacro.php

示例4: nodeOpened

	/**
	 * New node is found.
	 * @return bool
	 */
	public function nodeOpened(Latte\MacroNode $node)
	{
		$this->used = TRUE;
		$node->isEmpty = FALSE;
		$node->openingCode = Latte\PhpWriter::using($node)
			->write('<?php if (Nette\Bridges\CacheLatte\CacheMacro::createCache($netteCacheStorage, %var, $_g->caches, %node.array?)) { ?>',
				Nette\Utils\Random::generate()
			);
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:13,代码来源:CacheMacro.php

示例5: compile

 private function compile(MacroNode $node, $def)
 {
     $node->tokenizer->reset();
     $writer = PhpWriter::using($node, $this->compiler);
     if (is_string($def)) {
         return $writer->write($def);
     } else {
         return callback($def)->invoke($node, $writer);
     }
 }
开发者ID:davefu,项目名称:PermissionChecker,代码行数:10,代码来源:IfAllowedHrefMacro.php

示例6: macroLink

 /**
  * {link destination [,] [params]}
  * {plink destination [,] [params]}
  * n:href="destination [,] [params]"
  */
 public function macroLink(MacroNode $node, PhpWriter $writer)
 {
     $node->modifiers = preg_replace('#\\|safeurl\\s*(?=\\||\\z)#i', '', $node->modifiers);
     return $writer->using($node, $this->getCompiler())->write('echo %escape(%modify(' . ($node->name === 'plink' ? '$_presenter' : '$_control') . '->link(%node.word, %node.array?)))');
 }
开发者ID:TomasVotruba,项目名称:application,代码行数:10,代码来源:UIMacros.php

示例7: compile

 /**
  * Generates code.
  * @return string
  */
 private function compile(MacroNode $node, $def)
 {
     $node->tokenizer->reset();
     $writer = Latte\PhpWriter::using($node, $this->compiler);
     if (is_string($def)) {
         return $writer->write($def);
     } else {
         return call_user_func($def, $node, $writer);
     }
 }
开发者ID:richard-ejem,项目名称:latte,代码行数:14,代码来源:MacroSet.php

示例8: nodeOpened

 public function nodeOpened(MacroNode $node)
 {
     $this->used = true;
     $node->isEmpty = false;
     $node->openingCode = PhpWriter::using($node)->write('<?php if (Venne\\Latte\\Macros\\GlobalCacheMacro::createCache($netteCacheStorage, %var, $presenter->template->_g->caches, ' . var_export(self::$template, true) . ', %node.array?)) { ?>', Random::generate());
 }
开发者ID:venne,项目名称:venne,代码行数:6,代码来源:GlobalCacheMacro.php

示例9: compile

 /**
  * Generates code.
  * @return string
  */
 private function compile(MacroNode $node, $def)
 {
     $node->tokenizer->reset();
     $writer = Latte\PhpWriter::using($node);
     return is_string($def) ? $writer->write($def) : call_user_func($def, $node, $writer);
 }
开发者ID:nette,项目名称:latte,代码行数:10,代码来源:MacroSet.php

示例10: src

 public function src(\Latte\MacroNode $node, \Latte\PhpWriter $writer)
 {
     return $writer->using($node, $this->getCompiler())->write('echo %escape(\\App\\MacroSet::getSrc($_presenter, %node.word, %node.array?))');
 }
开发者ID:vsek,项目名称:cms,代码行数:4,代码来源:MacroSet.php

示例11: macroIfAllowed

 /**
  * @param \Latte\MacroNode $node
  * @param \Latte\PhpWriter $writer
  * @return string
  */
 public function macroIfAllowed(MacroNode $node, PhpWriter $writer)
 {
     $name = Random::generate();
     return $writer->using($node, $this->getCompiler())->write(sprintf('$_allow_%s=FALSE;try{$_presenter->getContext()->getByType("Ark8\\Security\\Validator")->onMacro(%%node.word,%%node.array);$_allow_%s=TRUE;}catch(\\Nette\\Application\\ForbiddenRequestException $e){}if($_allow_%s){', $name, $name, $name));
 }
开发者ID:ark8,项目名称:security,代码行数:10,代码来源:AuthorizatorMacros.php


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