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


PHP Application::user方法代碼示例

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


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

示例1: onControllerShoppingConfirmBefore

 /**
  * クーポンが利用されていないかチェック
  *
  */
 public function onControllerShoppingConfirmBefore($event = null)
 {
     $cartService = $this->app['eccube.service.cart'];
     $preOrderId = $cartService->getPreOrderId();
     if (is_null($preOrderId)) {
         return;
     }
     $repository = $this->app['eccube.plugin.coupon.repository.coupon_order'];
     // クーポン受注情報を取得する
     $CouponOrder = $repository->findOneBy(array('pre_order_id' => $preOrderId));
     if (!$CouponOrder) {
         return;
     }
     if ($this->app->isGranted('ROLE_USER')) {
         $Customer = $this->app->user();
     } else {
         $Customer = $this->app['eccube.service.shopping']->getNonMember($this->sessionKey);
     }
     // クーポンが既に利用されているかチェック
     $couponUsedOrNot = $this->app['eccube.plugin.coupon.service.coupon']->checkCouponUsedOrNotBefore($CouponOrder->getCouponCd(), $CouponOrder->getOrderId(), $Customer);
     if ($couponUsedOrNot) {
         $this->app->addError($this->app->trans('front.plugin.coupon.shopping.sameuser'), 'front.request');
         // 既に存在している
         if (is_null($event)) {
             header("Location: " . $this->app->url('shopping'));
             exit;
         } else {
             $response = $this->redirect($this->app->url('shopping'));
             $event->setResponse($response);
             return;
         }
     }
 }
開發者ID:EC-CUBE,項目名稱:coupon-plugin,代碼行數:37,代碼來源:Coupon.php

示例2: index

 /**
  * Index
  *
  * @param  Application $app
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function index(Application $app, Request $request)
 {
     $Customer = $app->user();
     $CustomerForRestore = clone $app->user();
     $previous_password = $Customer->getPassword();
     $Customer->setPassword($app['config']['default_password']);
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('entry', $Customer);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             if ($Customer->getPassword() === $app['config']['default_password']) {
                 $Customer->setPassword($previous_password);
             } else {
                 $Customer->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer));
             }
             $app['orm.em']->persist($Customer);
             $app['orm.em']->flush();
             return $app->redirect($app->url('mypage_change_complete'));
         } else {
             // invalidでもSession上の$app->user()が置き換えられてしまうため復元する
             $Customer = $CustomerForRestore;
             $this->getSecurity($app)->getToken()->setUser($Customer);
         }
     }
     return $app->renderView('Mypage/change.twig', array('form' => $form->createView()));
 }
開發者ID:hiroyasu55,項目名稱:ec-cube,代碼行數:35,代碼來源:ChangeController.php

示例3: index

 /**
  * 退會畫麵.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     $builder = $app->form();
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         switch ($request->get('mode')) {
             case 'confirm':
                 return $app->render('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
             case 'complete':
                 /* @var $Customer \Eccube\Entity\Customer */
                 $Customer = $app->user();
                 // 會員削除
                 $email = $Customer->getEmail();
                 // メールアドレスにダミーをセット
                 $Customer->setEmail(Str::random(60) . '@dummy.dummy');
                 $Customer->setDelFlg(Constant::ENABLED);
                 $app['orm.em']->flush();
                 $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event);
                 // メール送信
                 $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
                 // ログアウト
                 $this->getSecurity($app)->setToken(null);
                 return $app->redirect($app->url('mypage_withdraw_complete'));
         }
     }
     return $app->render('Mypage/withdraw.twig', array('form' => $form->createView()));
 }
開發者ID:shhirose,項目名稱:ec-cube,代碼行數:38,代碼來源:WithdrawController.php

示例4: index

 /**
  * Index
  *
  * @param  Application $app
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function index(Application $app, Request $request)
 {
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $app->form()->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             switch ($request->get('mode')) {
                 case 'confirm':
                     return $app->renderView('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
                 case 'complete':
                     /* @var $Customer \Eccube\Entity\Customer */
                     $Customer = $app->user();
                     // 會員削除
                     $email = $Customer->getEmail();
                     // メールアドレスにダミーをセット
                     $Customer->setEmail(Str::random(60) . '@dummy.dummy');
                     $Customer->setDelFlg(Constant::ENABLED);
                     $app['orm.em']->flush();
                     // メール送信
                     $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
                     // ログアウト
                     $this->getSecurity($app)->setToken(null);
                     return $app->redirect($app->url('mypage_withdraw_complete'));
             }
         }
     }
     return $app->renderView('Mypage/withdraw.twig', array('form' => $form->createView()));
 }
開發者ID:hiroyasu55,項目名稱:ec-cube,代碼行數:35,代碼來源:WithdrawController.php

示例5: index

 /**
  * 會員情報編集畫麵.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     $Customer = $app->user();
     $LoginCustomer = clone $Customer;
     $app['orm.em']->detach($LoginCustomer);
     $previous_password = $Customer->getPassword();
     $Customer->setPassword($app['config']['default_password']);
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('entry', $Customer);
     $event = new EventArgs(array('builder' => $builder, 'Customer' => $Customer), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_INITIALIZE, $event);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         if ($Customer->getPassword() === $app['config']['default_password']) {
             $Customer->setPassword($previous_password);
         } else {
             if ($Customer->getSalt() === null) {
                 $Customer->setSalt($app['eccube.repository.customer']->createSalt(5));
             }
             $Customer->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer));
         }
         $app['orm.em']->flush();
         $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_COMPLETE, $event);
         return $app->redirect($app->url('mypage_change_complete'));
     }
     $app['security']->getToken()->setUser($LoginCustomer);
     return $app->render('Mypage/change.twig', array('form' => $form->createView()));
 }
開發者ID:shhirose,項目名稱:ec-cube,代碼行數:38,代碼來源:ChangeController.php

示例6: index

 /**
  * Index
  *
  * @param  Application $app
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function index(Application $app, Request $request)
 {
     $Customer = $app->user();
     $previous_password = $Customer->getPassword();
     $Customer->setPassword($app['config']['default_password']);
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('entry', $Customer);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             switch ($request->get('mode')) {
                 case 'complete':
                     if ($Customer->getPassword() === $app['config']['default_password']) {
                         $Customer->setPassword($previous_password);
                     } else {
                         $Customer->setPassword($app['orm.em']->getRepository('Eccube\\Entity\\Customer')->encryptPassword($app, $Customer));
                     }
                     $app['orm.em']->persist($Customer);
                     $app['orm.em']->flush();
                     return $app->redirect($app->url('mypage_change_complete'));
             }
         }
     }
     return $app->renderView('Mypage/change.twig', array('form' => $form->createView()));
 }
開發者ID:nanasess,項目名稱:nagoya-eccube-study,代碼行數:33,代碼來源:ChangeController.php

示例7: history

 /**
  * @param  Application $app
  * @param  Request     $request
  * @return string
  */
 public function history(Application $app, Request $request, $id)
 {
     /* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
     $softDeleteFilter = $app['orm.em']->getFilters()->getFilter('soft_delete');
     $softDeleteFilter->setExcludes(array('Eccube\\Entity\\ProductClass'));
     $Order = $app['eccube.repository.order']->findOneBy(array('id' => $id, 'Customer' => $app->user()));
     if (!$Order) {
         throw new NotFoundHttpException();
     }
     return $app->render('Mypage/history.twig', array('Order' => $Order));
 }
開發者ID:noadless,項目名稱:ec-cube,代碼行數:16,代碼來源:MypageController.php

示例8: edit

 public function edit(Application $app, Request $request, $id = null)
 {
     $previous_password = null;
     if ($id) {
         $Member = $app['eccube.repository.member']->find($id);
         if (!$Member) {
             throw new NotFoundHttpException();
         }
         $previous_password = $Member->getPassword();
         $Member->setPassword($app['config']['default_password']);
     } else {
         $Member = new \Eccube\Entity\Member();
     }
     $LoginMember = clone $app->user();
     $app['orm.em']->detach($LoginMember);
     $builder = $app['form.factory']->createBuilder('admin_member', $Member);
     $event = new EventArgs(array('builder' => $builder, 'Member' => $Member), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SYSTEM_MEMBER_EDIT_INITIALIZE, $event);
     $form = $builder->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             if (!is_null($previous_password) && $Member->getpassword() === $app['config']['default_password']) {
                 // 編集時にPWを変更していなければ
                 // 変更前のパスワード(暗號化済み)をセット
                 $Member->setPassword($previous_password);
             } else {
                 $salt = $Member->getSalt();
                 if (!isset($salt)) {
                     $salt = $app['eccube.repository.member']->createSalt(5);
                     $Member->setSalt($salt);
                 }
                 // 入力されたPWを暗號化してセット
                 $password = $app['eccube.repository.member']->encryptPassword($Member);
                 $Member->setPassword($password);
             }
             $status = $app['eccube.repository.member']->save($Member);
             if ($status) {
                 $event = new EventArgs(array('form' => $form, 'Member' => $Member), $request);
                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SYSTEM_MEMBER_EDIT_COMPLETE, $event);
                 $app->addSuccess('admin.member.save.complete', 'admin');
                 return $app->redirect($app->url('admin_setting_system_member'));
             } else {
                 $app->addError('admin.member.save.error', 'admin');
             }
         }
     }
     $app['security']->getToken()->setUser($LoginMember);
     return $app->render('Setting/System/member_edit.twig', array('form' => $form->createView(), 'Member' => $Member));
 }
開發者ID:ec-cube,項目名稱:ec-cube,代碼行數:50,代碼來源:MemberController.php

示例9: processPurchase

 /**
  * 購入処理を行う
  *
  * @param Order $Order
  * @throws ShoppingException
  */
 public function processPurchase(Order $Order)
 {
     $em = $this->app['orm.em'];
     // 合計金額の再計算
     $this->calculatePrice($Order);
     // 商品公開ステータスチェック、商品製限數チェック、在庫チェック
     $check = $this->isOrderProduct($em, $Order);
     if (!$check) {
         throw new ShoppingException('front.shopping.stock.error');
     }
     // 受注情報、配送情報を更新
     $Order = $this->calculateDeliveryFee($Order);
     $this->setOrderUpdateData($Order);
     // 在庫情報を更新
     $this->setStockUpdate($em, $Order);
     if ($this->app->isGranted('ROLE_USER')) {
         // 會員の場合、購入金額を更新
         $this->setCustomerUpdate($Order, $this->app->user());
     }
 }
開發者ID:shhirose,項目名稱:ec-cube,代碼行數:26,代碼來源:ShoppingService.php

示例10: index

 /**
  * Index
  * 
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     $Customer = $app->user();
     $LoginCustomer = clone $Customer;
     $app['orm.em']->detach($LoginCustomer);
     $previous_password = $Customer->getPassword();
     $Customer->setPassword($app['config']['default_password']);
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('entry', $Customer);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         if ($Customer->getPassword() === $app['config']['default_password']) {
             $Customer->setPassword($previous_password);
         } else {
             $Customer->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer));
         }
         $app['orm.em']->flush();
         return $app->redirect($app->url('mypage_change_complete'));
     }
     $app['security']->getToken()->setUser($LoginCustomer);
     return $app->renderView('Mypage/change.twig', array('form' => $form->createView()));
 }
開發者ID:rikkeisoft,項目名稱:ec-cube,代碼行數:31,代碼來源:ChangeController.php

示例11: changePassword

 /**
  * パスワード変更畫麵
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function changePassword(Application $app, Request $request)
 {
     $builder = $app['form.factory']->createBuilder('admin_change_password');
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ADMIM_CHANGE_PASSWORD_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $password = $form->get('change_password')->getData();
         $Member = $app->user();
         $dummyMember = clone $Member;
         $dummyMember->setPassword($password);
         $salt = $dummyMember->getSalt();
         if (!isset($salt)) {
             $salt = $app['eccube.repository.member']->createSalt(5);
             $dummyMember->setSalt($salt);
         }
         $encryptPassword = $app['eccube.repository.member']->encryptPassword($dummyMember);
         $Member->setPassword($encryptPassword)->setSalt($salt);
         $status = $app['eccube.repository.member']->save($Member);
         if ($status) {
             $event = new EventArgs(array('form' => $form), $request);
             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ADMIN_CHANGE_PASSWORD_COMPLETE, $event);
             $app->addSuccess('admin.change_password.save.complete', 'admin');
             return $app->redirect($app->url('admin_change_password'));
         }
         $app->addError('admin.change_password.save.error', 'admin');
     }
     return $app->render('change_password.twig', array('form' => $form->createView()));
 }
開發者ID:ec-cube,項目名稱:ec-cube,代碼行數:37,代碼來源:AdminController.php

示例12: favorite

 /**
  * @param Application $app
  * @param Request     $request
  *
  * @return string
  */
 public function favorite(Application $app, Request $request)
 {
     $Customer = $app->user();
     // paginator
     $qb = $app['eccube.repository.product']->getFavoriteProductQueryBuilderByCustomer($Customer);
     $pagination = $app['paginator']()->paginate($qb, $request->get('pageno', 1), $app['config']['search_pmax']);
     return $app->render('Mypage/favorite.twig', array('pagination' => $pagination));
 }
開發者ID:prospdragon,項目名稱:ec-cube,代碼行數:14,代碼來源:MypageController.php

示例13: login

 /**
  * ログイン
  */
 public function login(Application $app, Request $request)
 {
     if (!$app['eccube.service.cart']->isLocked()) {
         return $app->redirect($app->url('cart'));
     }
     if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
         return $app->redirect($app->url('shopping'));
     }
     /* @var $form \Symfony\Component\Form\FormInterface */
     $builder = $app['form.factory']->createNamedBuilder('', 'customer_login');
     if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $Customer = $app->user();
         if ($Customer) {
             $builder->get('login_email')->setData($Customer->getEmail());
         }
     }
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_LOGIN_INITIALIZE, $event);
     $form = $builder->getForm();
     return $app->render('Shopping/login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView()));
 }
開發者ID:ec-cube,項目名稱:ec-cube,代碼行數:24,代碼來源:ShoppingController.php

示例14: favorite

 /**
  * @param Application $app
  * @param Request     $request
  *
  * @return string
  */
 public function favorite(Application $app, Request $request)
 {
     $BaseInfo = $app['eccube.repository.base_info']->get();
     if ($BaseInfo->getOptionFavoriteProduct() == Constant::ENABLED) {
         $Customer = $app->user();
         // paginator
         $qb = $app['eccube.repository.product']->getFavoriteProductQueryBuilderByCustomer($Customer);
         $pagination = $app['paginator']()->paginate($qb, $request->get('pageno', 1), $app['config']['search_pmax']);
         return $app->render('Mypage/favorite.twig', array('pagination' => $pagination));
     } else {
         throw new NotFoundHttpException();
     }
 }
開發者ID:rikkeisoft,項目名稱:ec-cube,代碼行數:19,代碼來源:MypageController.php

示例15: review

 public function review(Application $app, Request $request, $id)
 {
     /* @var $Product \Eccube\Entity\Product */
     $Product = $app['eccube.repository.product']->get($id);
     if (!$request->getSession()->has('_security_admin') && $Product->getStatus()->getId() !== 1) {
         throw new NotFoundHttpException();
     }
     if (count($Product->getProductClasses()) < 1) {
         throw new NotFoundHttpException();
     }
     $ProductReview = new \Plugin\ProductReview\Entity\ProductReview();
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('product_review', $ProductReview);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     if ($request->getMethod() === 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             switch ($request->get('mode')) {
                 case 'confirm':
                     $builder->setAttribute('freeze', true);
                     $form = $builder->getForm();
                     $form->handleRequest($request);
                     return $app['twig']->render('ProductReview/Resource/template/default/confirm.twig', array('form' => $form->createView(), 'Product' => $Product));
                     break;
                 case 'complete':
                     /** @var $ProductReview \Plugin\ProductReview\Entity\ProductReview */
                     $ProductReview = $form->getData();
                     if ($app->isGranted('ROLE_USER')) {
                         $Customer = $app->user();
                         $ProductReview->setCustomer($Customer);
                     }
                     $ProductReview->setProduct($Product);
                     $Disp = $app['eccube.repository.master.disp']->find(\Eccube\Entity\Master\Disp::DISPLAY_HIDE);
                     $ProductReview->setStatus($Disp);
                     $ProductReview->setDelFlg(Constant::DISABLED);
                     $status = $app['eccube.plugin.product_review.repository.product_review']->save($ProductReview);
                     if (!$status) {
                         $app->addError('front.product_review.system.error');
                         return $app->redirect($app->url('products_detail_review_error'));
                     } else {
                         return $app->redirect($app->url('products_detail_review_complete', array('id' => $Product->getId())));
                     }
                     break;
             }
             return $app->redirect($app->url('admin_product_review'));
         }
     }
     return $app->render('ProductReview/Resource/template/default/index.twig', array('title' => $this->title, 'subtitle' => $Product->getName(), 'form' => $form->createView(), 'Product' => $Product));
 }
開發者ID:k-yamamura,項目名稱:ProductReview-plugin,代碼行數:50,代碼來源:ProductReviewController.php


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