本文整理匯總了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());
}
}
示例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();
}