本文整理汇总了PHP中Nette\Application\UI\Presenter::getParameterId方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::getParameterId方法的具体用法?PHP Presenter::getParameterId怎么用?PHP Presenter::getParameterId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::getParameterId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyMessagesToPayload
private function copyMessagesToPayload()
{
$id = $this->presenter->getParameterId('flash');
$messages = $this->presenter->getFlashSession()->{$id};
if (!$messages or !is_array($messages)) {
return;
}
$payload = $this->presenter->payload;
$payload->messageInfo = [];
$payload->messageError = [];
$payload->messageWarning = [];
$payload->messageSuccess = [];
foreach ($messages as $flash) {
$type = strtolower($flash->type);
if ($type == "success") {
$payload->messageSuccess[] = $flash->message;
} elseif ($type == "warning") {
$payload->messageWarning[] = $flash->message;
} elseif ($type == "error") {
$payload->messageError[] = $flash->message;
} else {
$payload->messageInfo[] = $flash->message;
}
}
if (count($payload->messageInfo) == 0) {
unset($payload->messageInfo);
}
if (count($payload->messageError) == 0) {
unset($payload->messageError);
}
if (count($payload->messageWarning) == 0) {
unset($payload->messageWarning);
}
if (count($payload->messageSuccess) == 0) {
unset($payload->messageSuccess);
}
}
示例2: createTemplate
/**
* Creates template and registers helpers and latte filter
* @param UI\Presenter $presenter
* @param string $file Filepath to file
* @param string|NULL $lang Lang code (length=2)
* @param string $class Name of template class
* @throws InvalidArgumentException
* @return Nette\Templating\IFileTemplate
*/
public function createTemplate(UI\Presenter $presenter, $file = NULL, $lang = NULL, $class = NULL)
{
$this->translator->setLangTo($lang);
$latte = $this->latteFactory->create();
$template = $class ? new $class($latte) : new Nette\Bridges\ApplicationLatte\Template($latte);
$template->getLatte()->addFilter(NULL, 'Nette\\Templating\\Helpers::loader');
$template->getLatte()->addFilter(NULL, '\\Helpers::loader');
array_unshift($latte->onCompile, function ($latte) {
$latte->getParser()->shortNoEscape = TRUE;
$latte->getCompiler()->addMacro('cache', new CacheMacro($latte->getCompiler()));
Nette\Bridges\ApplicationLatte\UIMacros::install($latte->getCompiler());
FormMacros::install($latte->getCompiler());
});
$latte->addFilter('url', 'rawurlencode');
// back compatiblity
foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
$latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
}
$template->setTranslator($this->translator);
if (!is_null($file)) {
$template->setFile($this->appDir . $file);
}
// default parameters
$template->control = $template->_control = $presenter;
$template->presenter = $template->_presenter = $presenter;
if ($presenter instanceof UI\Presenter) {
$template->user = $presenter->getUser();
$template->netteHttpResponse = $this->httpResponse;
$template->netteCacheStorage = $this->netteCacheStorage;
$template->baseUri = $template->baseUrl = rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/');
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
// flash message
if ($presenter->hasFlashSession()) {
$id = $presenter->getParameterId('flash');
$template->flashes = $presenter->getFlashSession()->{$id};
}
}
if (!isset($template->flashes) || !is_array($template->flashes)) {
$template->flashes = array();
}
return $template;
}