本文整理汇总了PHP中Nette\Environment::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getUser方法的具体用法?PHP Environment::getUser怎么用?PHP Environment::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Environment
的用法示例。
在下文中一共展示了Environment::getUser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTemplate
/**
* @return Nette\Templates\ITemplate
*/
protected function createTemplate()
{
$template = new Nette\Templates\FileTemplate();
$presenter = $this->getPresenter(FALSE);
$template->onPrepareFilters[] = callback($this, 'templatePrepareFilters');
// default parameters
$template->control = $this;
$template->presenter = $presenter;
$template->user = Nette\Environment::getUser();
$template->baseUri = Nette\Environment::getVariable('baseUri', NULL);
$template->basePath = rtrim($template->baseUri, '/');
// flash message
if ($presenter !== NULL && $presenter->hasFlashSession()) {
$id = $this->getParamId('flash');
$template->flashes = $presenter->getFlashSession()->{$id};
}
if (!isset($template->flashes) || !is_array($template->flashes)) {
$template->flashes = array();
}
// default helpers
$template->registerHelper('escape', 'Nette\\Templates\\TemplateHelpers::escapeHtml');
$template->registerHelper('escapeUrl', 'rawurlencode');
$template->registerHelper('stripTags', 'strip_tags');
$template->registerHelper('nl2br', 'nl2br');
$template->registerHelper('substr', 'iconv_substr');
$template->registerHelper('repeat', 'str_repeat');
$template->registerHelper('replaceRE', 'Nette\\String::replace');
$template->registerHelper('implode', 'implode');
$template->registerHelper('number', 'number_format');
$template->registerHelperLoader('Nette\\Templates\\TemplateHelpers::loader');
return $template;
}
示例2: getUser
public function getUser()
{
if (!$this->user) {
$this->user = Environment::getUser();
}
return $this->user;
}
示例3: __construct
/**
* Constructor
*
* @note Maybe get User by DI
*/
public function __construct()
{
if (class_exists('\\Nette\\Environment')) {
$this->userId = \Nette\Environment::getUser()->id;
$this->avaibleTables = \Nette\Environment::getConfig('store');
} else {
$this->userId = 0;
$this->avaibleTables = [];
}
}
示例4: loginFormSubmitted
public function loginFormSubmitted($form)
{
try {
$user = Environment::getUser();
$user->login($form['username']->getValue(), $form['password']->getValue());
$this->getApplication()->restoreRequest($this->backlink);
$this->redirect('Dashboard:');
} catch (AuthenticationException $e) {
$form->addError($e->getMessage());
}
}
示例5: actionLogout
public function actionLogout()
{
Environment::getUser()->logout();
$this->flashMessage('You have been logged off.');
$this->redirect('Auth:login');
}
示例6: thumb
public function thumb($id, $thumb, $test = FALSE)
{
$set = array("events_id" => $id, "account_id" => \Nette\Environment::getUser()->getId(), "host_ip" => $_SERVER["REMOTE_ADDR"], "host_addr" => gethostbyaddr($_SERVER["REMOTE_ADDR"]));
$res = dibi::select("*")->from("events_rating")->where($set)->fetchAll();
if (count($res) > 0) {
throw new \DibiException("Již jste jednou hlasovali. Své hlasování není možné nyní změnit.");
return false;
}
if (!$test) {
if ($thumb == "down") {
$set["thumb_down"] = 1;
} else {
$set["thumb_up"] = 1;
}
dibi::query("INSERT INTO events_rating", $set);
}
}
示例7: getUser
/**
* @return Nette\Web\User
*/
public function getUser()
{
return Environment::getUser();
}
示例8: getUser
/**
* @return Nette\Web\User
*/
protected function getUser()
{
return Environment::getUser();
}
示例9: getResourceId
/**
* Returns resource ID for ACL
*
* @return string
*/
public function getResourceId()
{
if ($this->checkIfIdIsDefined() && count($this->metadata->getIdFields()) > 0) {
$ids = array();
foreach ($this->metadata->getIdFields() as $name) {
$ids[] = $this->data->{$name};
}
$resId = self::getParentResourceId() . '(' . implode($ids, ',') . ')';
$acl = Nette\Environment::getUser()->getAuthorizator();
if ($acl instanceof Nette\Security\Permission && !$acl->hasResource($resId)) {
if (!$acl->hasResource(static::getParentResourceId())) {
$acl->addResource(static::getParentResourceId());
}
$acl->addResource($resId, static::getParentResourceId());
}
return $resId;
} else {
return static::getParentResourceId();
}
}
示例10: beforeRender
protected function beforeRender()
{
$user = Environment::getUser();
$this->template->user = $user->isLoggedIn() ? $user->getIdentity() : NULL;
}