当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::addRequestError方法代码示例

本文整理汇总了PHP中Eccube\Application::addRequestError方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::addRequestError方法的具体用法?PHP Application::addRequestError怎么用?PHP Application::addRequestError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Eccube\Application的用法示例。


在下文中一共展示了Application::addRequestError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: down

 public function down(Application $app, $productClassId)
 {
     try {
         $app['eccube.service.cart']->downProductQuantity($productClassId)->save();
     } catch (CartException $e) {
         $app->addRequestError($e->getMessage());
     }
     return $app->redirect($app->url('cart'));
 }
开发者ID:nanasess,项目名称:nagoya-eccube-study,代码行数:9,代码来源:CartController.php

示例2: add

 public function add(Application $app, Request $request)
 {
     $productClassId = $request->get('product_class_id');
     $quantity = $request->request->has('quantity') ? $request->get('quantity') : 1;
     try {
         $app['eccube.service.cart']->addProduct($productClassId, $quantity)->save();
     } catch (CartException $e) {
         $app->addRequestError($e->getMessage());
     }
     return $app->redirect($app->url('cart'));
 }
开发者ID:geany-y,项目名称:LikeNiko,代码行数:11,代码来源:CartController.php

示例3: detail

 public function detail(Application $app, Request $request, $id)
 {
     $BaseInfo = $app['eccube.repository.base_info']->get();
     if ($BaseInfo->getNostockHidden() === Constant::ENABLED) {
         $app['orm.em']->getFilters()->enable('nostock_hidden');
     }
     /* @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();
     }
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createNamedBuilder('', 'add_cart', null, array('product' => $Product, 'id_add_product_id' => false));
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     if ($request->getMethod() === 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $addCartData = $form->getData();
             if ($addCartData['mode'] === 'add_favorite') {
                 if ($app->isGranted('ROLE_USER')) {
                     $Customer = $app->user();
                     $app['eccube.repository.customer_favorite_product']->addFavorite($Customer, $Product);
                     $app['session']->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId());
                     return $app->redirect($app->url('product_detail', array('id' => $Product->getId())));
                 } else {
                     // 非会員の場合、ログイン画面を表示
                     //  ログイン後の画面遷移先を設定
                     $app->setLoginTargetPath($app->url('product_detail', array('id' => $Product->getId())));
                     $app['session']->getFlashBag()->set('eccube.add.favorite', true);
                     return $app->redirect($app->url('mypage_login'));
                 }
             } else {
                 try {
                     $app['eccube.service.cart']->addProduct($addCartData['product_class_id'], $addCartData['quantity'])->save();
                 } catch (CartException $e) {
                     $app->addRequestError($e->getMessage());
                 }
                 return $app->redirect($app->url('cart'));
             }
         }
     } else {
         $addFavorite = $app['session']->getFlashBag()->get('eccube.add.favorite');
         if (!empty($addFavorite)) {
             // お気に入り登録時にログインされていない場合、ログイン後にお気に入り追加処理を行う
             if ($app->isGranted('ROLE_USER')) {
                 $Customer = $app->user();
                 $app['eccube.repository.customer_favorite_product']->addFavorite($Customer, $Product);
                 $app['session']->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId());
             }
         }
     }
     $is_favorite = false;
     if ($app->isGranted('ROLE_USER')) {
         $Customer = $app->user();
         $is_favorite = $app['eccube.repository.customer_favorite_product']->isFavorite($Customer, $Product);
     }
     return $app->render('Product/detail.twig', array('title' => $this->title, 'subtitle' => $Product->getName(), 'form' => $form->createView(), 'Product' => $Product, 'is_favorite' => $is_favorite));
 }
开发者ID:hiroyasu55,项目名称:ec-cube,代码行数:62,代码来源:ProductController.php

示例4: nonmember

 /**
  * 非会員処理
  */
 public function nonmember(Application $app, Request $request)
 {
     $cartService = $app['eccube.service.cart'];
     // カートチェック
     if (!$cartService->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     // ログイン済みの場合は, 購入画面へリダイレクト.
     if ($app->isGranted('ROLE_USER')) {
         return $app->redirect($app->url('shopping'));
     }
     // カートチェック
     if (count($cartService->getCart()->getCartItems()) <= 0) {
         // カートが存在しない時はエラー
         return $app->redirect($app->url('cart'));
     }
     $form = $app['form.factory']->createBuilder('nonmember')->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getData();
         $Customer = new Customer();
         $Customer->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setEmail($data['email'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02']);
         // 非会員複数配送用
         $CustomerAddress = new CustomerAddress();
         $CustomerAddress->setCustomer($Customer)->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02'])->setDelFlg(Constant::DISABLED);
         $Customer->addCustomerAddress($CustomerAddress);
         // 受注情報を取得
         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
         // 初回アクセス(受注データがない)の場合は, 受注情報を作成
         if (is_null($Order)) {
             // 受注情報を作成
             try {
                 // 受注情報を作成
                 $app['eccube.service.shopping']->createOrder($Customer);
             } catch (CartException $e) {
                 $app->addRequestError($e->getMessage());
                 return $app->redirect($app->url('cart'));
             }
         }
         // 非会員用セッションを作成
         $nonMember = array();
         $nonMember['customer'] = $Customer;
         $nonMember['pref'] = $Customer->getPref()->getId();
         $app['session']->set($this->sessionKey, $nonMember);
         $customerAddresses = array();
         $customerAddresses[] = $CustomerAddress;
         $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
         return $app->redirect($app->url('shopping'));
     }
     return $app->render('Shopping/nonmember.twig', array('form' => $form->createView()));
 }
开发者ID:rikkeisoft,项目名称:ec-cube,代码行数:55,代码来源:ShoppingController.php

示例5: add

 /**
  * カートに商品を追加する.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function add(Application $app, Request $request)
 {
     $productClassId = $request->get('product_class_id');
     $quantity = $request->request->has('quantity') ? $request->get('quantity') : 1;
     // FRONT_CART_ADD_INITIALIZE
     $event = new EventArgs(array('productClassId' => $productClassId, 'quantity' => $quantity), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_ADD_INITIALIZE, $event);
     try {
         $productClassId = $event->getArgument('productClassId');
         $quantity = $event->getArgument('quantity');
         log_info('カート追加処理開始', array('product_class_id' => $productClassId, 'quantity' => $quantity));
         $app['eccube.service.cart']->addProduct($productClassId, $quantity)->save();
         log_info('カート追加処理完了', array('product_class_id' => $productClassId, 'quantity' => $quantity));
         // FRONT_CART_ADD_COMPLETE
         $event = new EventArgs(array('productClassId' => $productClassId, 'quantity' => $quantity), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_ADD_COMPLETE, $event);
         if ($event->hasResponse()) {
             return $event->getResponse();
         }
     } catch (CartException $e) {
         log_info('カート追加エラー', array($e->getMessage()));
         // FRONT_CART_ADD_EXCEPTION
         $event = new EventArgs(array('exception' => $e), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_ADD_EXCEPTION, $event);
         if ($event->hasResponse()) {
             return $event->getResponse();
         }
         $app->addRequestError($e->getMessage());
     }
     return $app->redirect($app->url('cart'));
 }
开发者ID:ec-cube,项目名称:ec-cube,代码行数:38,代码来源:CartController.php

示例6: index

 /**
  * 購入画面表示
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function index(Application $app, Request $request)
 {
     $cartService = $app['eccube.service.cart'];
     // カートチェック
     if (!$cartService->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     // カートチェック
     if (count($cartService->getCart()->getCartItems()) <= 0) {
         // カートが存在しない時はエラー
         return $app->redirect($app->url('cart'));
     }
     // 登録済みの受注情報を取得
     $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
     // 初回アクセス(受注情報がない)の場合は, 受注情報を作成
     if (is_null($Order)) {
         // 未ログインの場合, ログイン画面へリダイレクト.
         if (!$app->isGranted('IS_AUTHENTICATED_FULLY')) {
             // 非会員でも一度会員登録されていればショッピング画面へ遷移
             $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
             if (is_null($Customer)) {
                 return $app->redirect($app->url('shopping_login'));
             }
         } else {
             $Customer = $app->user();
         }
         // 受注情報を作成
         $Order = $app['eccube.service.shopping']->createOrder($Customer);
         $app['session']->remove($this->sessionMultipleKey);
     } else {
         // 計算処理
         $Order = $app['eccube.service.shopping']->getAmount($Order);
     }
     // 受注関連情報を最新状態に更新
     $app['orm.em']->refresh($Order);
     // form作成
     $form = $app['eccube.service.shopping']->getShippingForm($Order);
     // 合計数量
     $totalQuantity = $app['eccube.service.order']->getTotalQuantity($Order);
     // 複数配送の場合、エラーメッセージを一度だけ表示
     if (!$app['session']->has($this->sessionMultipleKey)) {
         if (count($Order->getShippings()) > 1) {
             $app->addRequestError('shopping.multiple.delivery');
         }
         $app['session']->set($this->sessionMultipleKey, 'multiple');
     }
     return $app->render('Shopping/index.twig', array('form' => $form->createView(), 'Order' => $Order, 'totalQuantity' => $totalQuantity));
 }
开发者ID:hiroaki-zeniya,项目名称:ec-cube,代码行数:56,代码来源:ShoppingController.php

示例7: nonmember

 /**
  * 非会員処理
  */
 public function nonmember(Application $app, Request $request)
 {
     $cartService = $app['eccube.service.cart'];
     // カートチェック
     if (!$cartService->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         log_info('カートが存在しません');
         return $app->redirect($app->url('cart'));
     }
     // ログイン済みの場合は, 購入画面へリダイレクト.
     if ($app->isGranted('ROLE_USER')) {
         return $app->redirect($app->url('shopping'));
     }
     // カートチェック
     if (count($cartService->getCart()->getCartItems()) <= 0) {
         // カートが存在しない時はエラー
         log_info('カートに商品が入っていないためショッピングカート画面にリダイレクト');
         return $app->redirect($app->url('cart'));
     }
     $builder = $app['form.factory']->createBuilder('nonmember');
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         log_info('非会員お客様情報登録開始');
         $data = $form->getData();
         $Customer = new Customer();
         $Customer->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setEmail($data['email'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02']);
         // 非会員複数配送用
         $CustomerAddress = new CustomerAddress();
         $CustomerAddress->setCustomer($Customer)->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02'])->setDelFlg(Constant::DISABLED);
         $Customer->addCustomerAddress($CustomerAddress);
         // 受注情報を取得
         $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
         // 初回アクセス(受注データがない)の場合は, 受注情報を作成
         if (is_null($Order)) {
             // 受注情報を作成
             try {
                 // 受注情報を作成
                 $Order = $app['eccube.service.shopping']->createOrder($Customer);
             } catch (CartException $e) {
                 $app->addRequestError($e->getMessage());
                 return $app->redirect($app->url('cart'));
             }
         }
         // 非会員用セッションを作成
         $nonMember = array();
         $nonMember['customer'] = $Customer;
         $nonMember['pref'] = $Customer->getPref()->getId();
         $app['session']->set($this->sessionKey, $nonMember);
         $customerAddresses = array();
         $customerAddresses[] = $CustomerAddress;
         $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
         $event = new EventArgs(array('form' => $form, 'Order' => $Order), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_COMPLETE, $event);
         if ($event->getResponse() !== null) {
             return $event->getResponse();
         }
         log_info('非会員お客様情報登録完了', array($Order->getId()));
         return $app->redirect($app->url('shopping'));
     }
     return $app->render('Shopping/nonmember.twig', array('form' => $form->createView()));
 }
开发者ID:ec-cube,项目名称:ec-cube,代码行数:67,代码来源:ShoppingController.php

示例8: detail

 public function detail(Application $app, Request $request, $id)
 {
     if ($app['config']['nostock_hidden']) {
         $app['orm.em']->getFilters()->enable('nostock_hidden');
     }
     /* @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();
     }
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createNamedBuilder('', 'add_cart', null, array('product' => $Product, 'id_add_product_id' => false));
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     if ($request->getMethod() === 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $addCartData = $form->getData();
             if ($addCartData['mode'] === 'add_favorite') {
                 if ($app['security']->isGranted('ROLE_USER')) {
                     $Customer = $app['security']->getToken()->getUser();
                     $app['eccube.repository.customer_favorite_product']->addFavorite($Customer, $Product);
                     $app['session']->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId());
                 }
                 return $app->redirect($app->url('product_detail', array('productId' => $Product->getId())));
             } else {
                 try {
                     $app['eccube.service.cart']->addProduct($addCartData['product_class_id'], $addCartData['quantity'])->save();
                 } catch (CartException $e) {
                     $app->addRequestError($e->getMessage());
                 }
                 return $app->redirect($app->url('cart'));
             }
         }
     }
     if ($app['security']->isGranted('ROLE_USER')) {
         $Customer = $app['security']->getToken()->getUser();
         $is_favorite = $app['eccube.repository.customer_favorite_product']->isFavorite($Customer, $Product);
     } else {
         $is_favorite = false;
     }
     return $app->render('Product/detail.twig', array('title' => $this->title, 'subtitle' => $Product->getName(), 'form' => $form->createView(), 'Product' => $Product, 'is_favorite' => $is_favorite));
 }
开发者ID:noadless,项目名称:ec-cube,代码行数:43,代码来源:ProductController.php


注:本文中的Eccube\Application::addRequestError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。