當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::setUser方法代碼示例

本文整理匯總了PHP中Magento\Backend\Model\Auth\Session::setUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::setUser方法的具體用法?PHP Session::setUser怎麽用?PHP Session::setUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Backend\Model\Auth\Session的用法示例。


在下文中一共展示了Session::setUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run installation in context of the specified admin user
  *
  * @param $userName
  * @param array $modules
  * @return void
  * @throws \Exception
  */
 public function run($userName, array $modules = [])
 {
     set_time_limit(0);
     /** @var \Magento\User\Model\User $user */
     $user = $this->userFactory->create()->loadByUsername($userName);
     if (!$user->getId()) {
         throw new \Exception('Invalid admin user provided');
     }
     $this->state->start();
     $this->session->setUser($user);
     $this->deploy->run();
     $resources = $this->initResources($modules);
     $this->state->clearErrorFlag();
     try {
         foreach ($this->moduleList->getNames() as $moduleName) {
             if (isset($resources[$moduleName])) {
                 $resourceType = $resources[$moduleName];
                 $this->setupFactory->create($resourceType)->run();
                 $this->postInstaller->addModule($moduleName);
             }
         }
         $this->session->unsUser();
         $this->postInstaller->run();
         $this->state->finish();
     } catch (\Exception $e) {
         $this->state->setError();
         $this->logger->log($e->getMessage());
     }
 }
開發者ID:vinai-drive-by-commits,項目名稱:magento2-sample-data,代碼行數:37,代碼來源:Installer.php

示例2: run

 /**
  * Run installation in context of the specified admin user
  *
  * @param \Magento\User\Model\User $adminUser
  * @throws \Exception
  *
  * @return void
  */
 public function run(\Magento\User\Model\User $adminUser)
 {
     set_time_limit(3600);
     if (!$adminUser || !$adminUser->getId()) {
         throw new \Exception('Invalid admin user provided');
     }
     $this->session->setUser($adminUser);
     $this->deploy->run();
     $resources = $this->initResources();
     foreach ($this->moduleList->getNames() as $moduleName) {
         if (isset($resources[$moduleName])) {
             $resourceType = $resources[$moduleName];
             $this->setupFactory->create($resourceType)->run();
             $this->postInstaller->addModule($moduleName);
         }
     }
     $this->session->unsUser();
     $this->postInstaller->run();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:27,代碼來源:Installer.php


注:本文中的Magento\Backend\Model\Auth\Session::setUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。