本文整理汇总了PHP中Nette\Application\UI\Presenter::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::getUser方法的具体用法?PHP Presenter::getUser怎么用?PHP Presenter::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::getUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startup
public function startup()
{
parent::startup();
$this->basePath = $this->template->basePath;
$this->publicPath = $this->basePath . '/www';
$this->user = parent::getUser();
$this->activeMenuItem = 'Homepage';
if ($this->user->isLoggedIn()) {
$this->user->startup();
}
}
示例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;
}
示例3: startup
protected function startup()
{
parent::startup();
$user = parent::getUser();
$user->getStorage()->setNamespace('App\\ClientModule');
}
示例4: getUser
public function getUser()
{
$user = parent::getUser();
$user->getStorage()->setNamespace('App\\AdminModule');
return $user;
}