當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。