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


PHP Environment::getUser方法代码示例

本文整理汇总了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;
 }
开发者ID:JPalounek,项目名称:IconStore,代码行数:35,代码来源:Control.php

示例2: getUser

 public function getUser()
 {
     if (!$this->user) {
         $this->user = Environment::getUser();
     }
     return $this->user;
 }
开发者ID:GymvodNette,项目名称:cv2-authentizace,代码行数:7,代码来源:BasePresenter.php

示例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 = [];
     }
 }
开发者ID:kravcik,项目名称:core,代码行数:15,代码来源:StoreManager.php

示例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());
     }
 }
开发者ID:jakubkulhan,项目名称:nette,代码行数:11,代码来源:AuthPresenter.php

示例5: actionLogout

 public function actionLogout()
 {
     Environment::getUser()->logout();
     $this->flashMessage('You have been logged off.');
     $this->redirect('Auth:login');
 }
开发者ID:jakubkulhan,项目名称:nette,代码行数:6,代码来源:DashboardPresenter.php

示例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);
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:17,代码来源:ModelEvents.php

示例7: getUser

 /**
  * @return Nette\Web\User
  */
 public function getUser()
 {
     return Environment::getUser();
 }
开发者ID:jff15,项目名称:travelbot,代码行数:7,代码来源:Presenter.php

示例8: getUser

 /**
  * @return Nette\Web\User
  */
 protected function getUser()
 {
     return Environment::getUser();
 }
开发者ID:nella,项目名称:ActiveMapper,代码行数:7,代码来源:Presenter.php

示例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();
     }
 }
开发者ID:vbuilder,项目名称:framework,代码行数:25,代码来源:ActiveEntity.php

示例10: beforeRender

 protected function beforeRender()
 {
     $user = Environment::getUser();
     $this->template->user = $user->isLoggedIn() ? $user->getIdentity() : NULL;
 }
开发者ID:jakubkulhan,项目名称:nette,代码行数:5,代码来源:BasePresenter.php


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