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


PHP Control::templatePrepareFilters方法代码示例

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


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

示例1: createTemplate

 /**
  * @return Template
  */
 public function createTemplate(UI\Control $control = NULL)
 {
     $latte = $this->latteFactory->create();
     $template = new Template($latte);
     $presenter = $control ? $control->getPresenter(FALSE) : NULL;
     if ($control instanceof UI\Presenter) {
         $latte->setLoader(new Loader($control));
     }
     if ($latte->onCompile instanceof \Traversable) {
         $latte->onCompile = iterator_to_array($latte->onCompile);
     }
     array_unshift($latte->onCompile, function ($latte) use($control, $template) {
         $latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
         UIMacros::install($latte->getCompiler());
         if (class_exists(Nette\Bridges\FormsLatte\FormMacros::class)) {
             Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
         }
         if ($control) {
             $control->templatePrepareFilters($template);
         }
     });
     $latte->addFilter('url', 'rawurlencode');
     // back compatiblity
     foreach (['normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse'] as $name) {
         $latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
     }
     $latte->addFilter('null', function () {
     });
     $latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
         return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
         // intentionally ==
     });
     if (!isset($latte->getFilters()['translate'])) {
         $latte->addFilter('translate', function (Latte\Runtime\FilterInfo $fi) {
             throw new Nette\InvalidStateException('Translator has not been set. Set translator using $template->setTranslator().');
         });
     }
     // default parameters
     $template->user = $this->user;
     $template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
     $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
     $template->flashes = [];
     if ($control) {
         $template->control = $control;
         $template->presenter = $presenter;
         $latte->addProvider('uiControl', $control);
         $latte->addProvider('uiPresenter', $presenter);
         $latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($control));
     }
     $latte->addProvider('cacheStorage', $this->cacheStorage);
     // back compatibility
     $template->_control = $control;
     $template->_presenter = $presenter;
     $template->netteCacheStorage = $this->cacheStorage;
     if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
         $id = $control->getParameterId('flash');
         $template->flashes = (array) $presenter->getFlashSession()->{$id};
     }
     return $template;
 }
开发者ID:hrach,项目名称:nette-application,代码行数:63,代码来源:TemplateFactory.php

示例2: createTemplate

	/**
	 * @return Template
	 */
	public function createTemplate(UI\Control $control)
	{
		$latte = $this->latteFactory->create();
		$template = new Template($latte);
		$presenter = $control->getPresenter(FALSE);

		if ($control instanceof UI\Presenter) {
			$latte->setLoader(new Loader($control));
		}

		if ($latte->onCompile instanceof \Traversable) {
			$latte->onCompile = iterator_to_array($latte->onCompile);
		}

		array_unshift($latte->onCompile, function ($latte) use ($control, $template) {
			$latte->getParser()->shortNoEscape = TRUE;
			$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
			UIMacros::install($latte->getCompiler());
			if (class_exists('Nette\Bridges\FormsLatte\FormMacros')) {
				Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
			}
			$control->templatePrepareFilters($template);
		});

		$latte->addFilter('url', 'rawurlencode'); // back compatiblity
		foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
			$latte->addFilter($name, 'Nette\Utils\Strings::' . $name);
		}
		$latte->addFilter('null', function () {});
		$latte->addFilter('length', function ($var) {
			return is_string($var) ? Nette\Utils\Strings::length($var) : count($var);
		});
		$latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
			return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally ==
		});

		// default parameters
		$template->control = $template->_control = $control;
		$template->presenter = $template->_presenter = $presenter;
		$template->user = $this->user;
		$template->netteHttpResponse = $this->httpResponse;
		$template->netteCacheStorage = $this->cacheStorage;
		$template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
		$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
		$template->flashes = array();

		if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
			$id = $control->getParameterId('flash');
			$template->flashes = (array) $presenter->getFlashSession()->$id;
		}

		return $template;
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:56,代码来源:TemplateFactory.php

示例3: createTemplate

 /**
  * @return Template
  */
 public function createTemplate(UI\Control $control)
 {
     $latte = $this->latteFactory->create();
     $template = new Template($latte);
     $presenter = $control->getPresenter(FALSE);
     if ($control instanceof UI\Presenter) {
         $latte->setLoader(new Loader($control));
     }
     if ($latte->onCompile instanceof \Traversable) {
         $latte->onCompile = iterator_to_array($latte->onCompile);
     }
     array_unshift($latte->onCompile, function ($latte) use($control, $template) {
         $latte->getParser()->shortNoEscape = TRUE;
         $latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
         UIMacros::install($latte->getCompiler());
         Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
         $control->templatePrepareFilters($template);
     });
     $latte->addFilter('url', 'rawurlencode');
     // back compatiblity
     foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
         $latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
     }
     // default parameters
     $template->control = $template->_control = $control;
     $template->presenter = $template->_presenter = $presenter;
     $template->user = $this->user;
     $template->netteHttpResponse = $this->httpResponse;
     $template->netteCacheStorage = $this->cacheStorage;
     $template->baseUri = $template->baseUrl = rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/');
     $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
     $template->flashes = array();
     if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
         $id = $control->getParameterId('flash');
         $template->flashes = (array) $presenter->getFlashSession()->{$id};
     }
     return $template;
 }
开发者ID:prcharom,项目名称:w-pps-reality,代码行数:41,代码来源:TemplateFactory.php


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