本文整理匯總了PHP中Library\Utility\Helper::getSession方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helper::getSession方法的具體用法?PHP Helper::getSession怎麽用?PHP Helper::getSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Library\Utility\Helper
的用法示例。
在下文中一共展示了Helper::getSession方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: avatarAction
public function avatarAction()
{
try {
/**
* @var \DDD\Service\Upload $uploadService
*/
$uploadService = $this->getServiceLocator()->get('service_upload');
$request = $this->getRequest();
// check request method
if ($request->getMethod() !== 'POST') {
throw new \Exception(TextConstants::AJAX_NO_POST_ERROR);
}
// take avatar file and user id from POST
$avatarFile = $request->getFiles();
$profileId = $request->getPost('userId');
// send resoult to service
$newAvatar = $uploadService->updateAvatar((int) $profileId, [$avatarFile['file']]);
if (is_array($newAvatar) && $newAvatar['status'] === 'error') {
return new JsonModel($newAvatar);
}
$session = Helper::getSession('Zend_Auth');
$session['storage']->avatar = $newAvatar;
$result['status'] = 'success';
$result['msg'] = TextConstants::SUCCESS_UPDATE;
$result['src'] = $profileId . '/' . $newAvatar;
return new JsonModel($result);
} catch (Exception $e) {
throw new \Exception($e->getMessage());
}
}