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


PHP Application::isGranted方法代码示例

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


在下文中一共展示了Application::isGranted方法的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: login

 public function login(Application $app, Request $request)
 {
     if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
         return $app->redirect($app->url('mypage'));
     }
     /* @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());
         }
     }
     $form = $builder->getForm();
     return $app->render('Mypage/login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView()));
 }
开发者ID:nanasess,项目名称:nagoya-eccube-study,代码行数:16,代码来源:MypageController.php

示例3: index

 public function index(Application $app, Request $request)
 {
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('contact');
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     if ($app->isGranted('ROLE_USER')) {
         /* @var $user \Eccube\Entity\Customer */
         $user = $app['user'];
         $form->setData(array('name01' => $user->getName01(), 'name02' => $user->getName02(), 'kana01' => $user->getKana01(), 'kana02' => $user->getKana02(), 'zip01' => $user->getZip01(), 'zip02' => $user->getZip02(), 'pref' => $user->getPref(), 'addr01' => $user->getAddr01(), 'addr02' => $user->getAddr02(), 'tel01' => $user->getTel01(), 'tel02' => $user->getTel02(), 'tel03' => $user->getTel03(), 'email' => $user->getEmail()));
     }
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         switch ($request->get('mode')) {
             case 'confirm':
                 $builder->setAttribute('freeze', true);
                 $form = $builder->getForm();
                 $form->handleRequest($request);
                 return $app->render('Contact/confirm.twig', array('form' => $form->createView()));
             case 'complete':
                 // メール送信
                 $app['eccube.service.mail']->sendContactMail($form->getData());
                 return $app->redirect($app->url('contact_complete'));
         }
     }
     return $app->render('Contact/index.twig', array('form' => $form->createView()));
 }
开发者ID:rikkeisoft,项目名称:ec-cube,代码行数:27,代码来源:ContactController.php

示例4: 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.factory']->createBuilder('contact');
     if ($app->isGranted('ROLE_USER')) {
         $user = $app['user'];
         $builder->setData(array('name01' => $user->getName01(), 'name02' => $user->getName02(), 'kana01' => $user->getKana01(), 'kana02' => $user->getKana02(), 'zip01' => $user->getZip01(), 'zip02' => $user->getZip02(), 'pref' => $user->getPref(), 'addr01' => $user->getAddr01(), 'addr02' => $user->getAddr02(), 'tel01' => $user->getTel01(), 'tel02' => $user->getTel02(), 'tel03' => $user->getTel03(), 'email' => $user->getEmail()));
     }
     // FRONT_CONTACT_INDEX_INITIALIZE
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         switch ($request->get('mode')) {
             case 'confirm':
                 $builder->setAttribute('freeze', true);
                 $form = $builder->getForm();
                 $form->handleRequest($request);
                 $title = 'お問い合わせ(確認ページ)';
                 return $app->render('Contact/confirm.twig', array('form' => $form->createView(), 'title' => $title));
             case 'complete':
                 $data = $form->getData();
                 $event = new EventArgs(array('form' => $form, 'data' => $data), $request);
                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_COMPLETE, $event);
                 $data = $event->getArgument('data');
                 // メール送信
                 $app['eccube.service.mail']->sendContactMail($data);
                 return $app->redirect($app->url('contact_complete'));
         }
     }
     return $app->render('Contact/index.twig', array('form' => $form->createView()));
 }
开发者ID:ryo-endo,项目名称:ec-cube,代码行数:39,代码来源:ContactController.php

示例5: login

 /**
  * ログイン画面.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function login(Application $app, Request $request)
 {
     if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
         return $app->redirect($app->url('mypage'));
     }
     /* @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_MYPAGE_MYPAGE_LOGIN_INITIALIZE, $event);
     $form = $builder->getForm();
     return $app->render('Mypage/login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView()));
 }
开发者ID:shhirose,项目名称:ec-cube,代码行数:25,代码来源:MypageController.php

示例6: login

 public function login(Application $app, Request $request)
 {
     if ($app->isGranted('ROLE_ADMIN')) {
         return $app->redirect($app->url('admin_homepage'));
     }
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $app['form.factory']->createNamedBuilder('', 'admin_login')->getForm();
     return $app['view']->render('login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView()));
 }
开发者ID:ygeneration666,项目名称:ec,代码行数:9,代码来源:AdminController.php

示例7: index

 /**
  * 会員登録画面.
  *
  * @param  Application $app
  * @param  Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     if ($app->isGranted('ROLE_USER')) {
         log_info('認証済のためログイン処理をスキップ');
         return $app->redirect($app->url('mypage'));
     }
     /** @var $Customer \Eccube\Entity\Customer */
     $Customer = $app['eccube.repository.customer']->newCustomer();
     /* @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_ENTRY_INDEX_INITIALIZE, $event);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         switch ($request->get('mode')) {
             case 'confirm':
                 log_info('会員登録確認開始');
                 $builder->setAttribute('freeze', true);
                 $form = $builder->getForm();
                 $form->handleRequest($request);
                 log_info('会員登録確認完了');
                 return $app->render('Entry/confirm.twig', array('form' => $form->createView()));
             case 'complete':
                 log_info('会員登録開始');
                 $Customer->setSalt($app['eccube.repository.customer']->createSalt(5))->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer))->setSecretKey($app['eccube.repository.customer']->getUniqueSecretKey($app));
                 $CustomerAddress = new \Eccube\Entity\CustomerAddress();
                 $CustomerAddress->setFromCustomer($Customer);
                 $app['orm.em']->persist($Customer);
                 $app['orm.em']->persist($CustomerAddress);
                 $app['orm.em']->flush();
                 log_info('会員登録完了');
                 $event = new EventArgs(array('form' => $form, 'Customer' => $Customer, 'CustomerAddress' => $CustomerAddress), $request);
                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_ENTRY_INDEX_COMPLETE, $event);
                 $activateUrl = $app->url('entry_activate', array('secret_key' => $Customer->getSecretKey()));
                 /** @var $BaseInfo \Eccube\Entity\BaseInfo */
                 $BaseInfo = $app['eccube.repository.base_info']->get();
                 $activateFlg = $BaseInfo->getOptionCustomerActivate();
                 // 仮会員設定が有効な場合は、確認メールを送信し完了画面表示.
                 if ($activateFlg) {
                     // メール送信
                     $app['eccube.service.mail']->sendCustomerConfirmMail($Customer, $activateUrl);
                     if ($event->hasResponse()) {
                         return $event->getResponse();
                     }
                     log_info('仮会員登録完了画面へリダイレクト');
                     return $app->redirect($app->url('entry_complete'));
                     // 仮会員設定が無効な場合は認証URLへ遷移させ、会員登録を完了させる.
                 } else {
                     log_info('本会員登録画面へリダイレクト');
                     return $app->redirect($activateUrl);
                 }
         }
     }
     return $app->render('Entry/index.twig', array('form' => $form->createView()));
 }
开发者ID:ec-cube,项目名称:ec-cube,代码行数:64,代码来源:EntryController.php

示例8: login

 public function login(Application $app, Request $request)
 {
     if ($app->isGranted('ROLE_ADMIN')) {
         return $app->redirect($app->url('admin_homepage'));
     }
     /* @var $form \Symfony\Component\Form\FormInterface */
     $builder = $app['form.factory']->createNamedBuilder('', 'admin_login');
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ADMIM_LOGIN_INITIALIZE, $event);
     $form = $builder->getForm();
     return $app->render('login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView()));
 }
开发者ID:ec-cube,项目名称:ec-cube,代码行数:12,代码来源:AdminController.php

示例9: copyToShippingFromCustomer

 /**
  * お届け先情報を作成
  *
  * @param \Eccube\Entity\Shipping $Shipping
  * @param \Eccube\Entity\Customer|null $Customer
  * @return \Eccube\Entity\Shipping
  */
 public function copyToShippingFromCustomer(Shipping $Shipping, Customer $Customer = null)
 {
     if (is_null($Customer)) {
         return $Shipping;
     }
     $CustomerAddress = $this->app['eccube.repository.customer_address']->findOneBy(array('Customer' => $Customer));
     if ($this->app->isGranted('ROLE_USER')) {
         $Shipping->setName01($CustomerAddress->getName01())->setName02($CustomerAddress->getName02())->setKana01($CustomerAddress->getKana01())->setKana02($CustomerAddress->getKana02())->setCompanyName($CustomerAddress->getCompanyName())->setTel01($CustomerAddress->getTel01())->setTel02($CustomerAddress->getTel02())->setTel03($CustomerAddress->getTel03())->setFax01($CustomerAddress->getFax01())->setFax02($CustomerAddress->getFax02())->setFax03($CustomerAddress->getFax03())->setZip01($CustomerAddress->getZip01())->setZip02($CustomerAddress->getZip02())->setZipCode($CustomerAddress->getZip01() . $CustomerAddress->getZip02())->setPref($CustomerAddress->getPref())->setAddr01($CustomerAddress->getAddr01())->setAddr02($CustomerAddress->getAddr02());
     } else {
         $Shipping->setName01($Customer->getName01())->setName02($Customer->getName02())->setKana01($Customer->getKana01())->setKana02($Customer->getKana02())->setCompanyName($Customer->getCompanyName())->setTel01($Customer->getTel01())->setTel02($Customer->getTel02())->setTel03($Customer->getTel03())->setFax01($Customer->getFax01())->setFax02($Customer->getFax02())->setFax03($Customer->getFax03())->setZip01($Customer->getZip01())->setZip02($Customer->getZip02())->setZipCode($Customer->getZip01() . $Customer->getZip02())->setPref($Customer->getPref())->setAddr01($Customer->getAddr01())->setAddr02($Customer->getAddr02());
     }
     return $Shipping;
 }
开发者ID:hiroaki-zeniya,项目名称:ec-cube,代码行数:20,代码来源:ShoppingService.php

示例10: 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

示例11: checkCouponUsedOrNotBefore

 /**
  *  ユーザはクーポン1回のみ利用できる
  *
  * @param $couponCd
  * @param $orderId
  * @param Customer $Customer
  * @return bool
  */
 public function checkCouponUsedOrNotBefore($couponCd, $orderId, Customer $Customer)
 {
     $repository = $this->app['eccube.plugin.coupon.repository.coupon_order'];
     if ($this->app->isGranted('ROLE_USER')) {
         $CouponOrders = $repository->findUseCouponBefore($couponCd, $orderId, $Customer->getId());
     } else {
         $CouponOrders = $repository->findUseCouponBefore($couponCd, $orderId, $Customer->getEmail());
     }
     if ($CouponOrders) {
         // 存在すれば既に受注として利用されていないかチェック
         foreach ($CouponOrders as $CouponOrder) {
             $Order = $this->app['eccube.repository.order']->find($CouponOrder->getOrderId());
             if ($Order) {
                 if ($Order->getOrderStatus()->getId() != $this->app['config']['order_processing']) {
                     // 同一のクーポンコードで既に受注データが存在している
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:EC-CUBE,项目名称:coupon-plugin,代码行数:30,代码来源:CouponService.php

示例12: 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();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             $Customer = new \Eccube\Entity\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']);
             // 受注関連情報を取得
             $preOrderId = $cartService->getPreOrderId();
             $Order = $app['eccube.repository.order']->findOneBy(array('pre_order_id' => $preOrderId, 'OrderStatus' => $app['config']['order_processing']));
             // 初回アクセス(受注データがない)の場合は, 受注データを作成
             if (is_null($Order)) {
                 // ランダムなpre_order_idを作成
                 $preOrderId = sha1(uniqid(mt_rand(), true));
                 // 受注情報、受注明細情報、お届け先情報、配送商品情報を作成
                 $app['eccube.service.order']->registerPreOrderFromCartItems($cartService->getCart()->getCartItems(), $Customer, $preOrderId);
                 $cartService->setPreOrderId($preOrderId);
                 $cartService->save();
             }
             // 非会員用セッションを作成
             $arr = array();
             $arr['customer'] = $Customer;
             $arr['pref'] = $Customer->getPref()->getId();
             $app['session']->set('eccube.front.shopping.nonmember', $arr);
             return $app->redirect($app->url('shopping'));
         }
     }
     return $app->render('Shopping/nonmember.twig', array('form' => $form->createView()));
 }
开发者ID:reh-d,项目名称:ec-cube3-test,代码行数:49,代码来源:ShoppingController.php

示例13: 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

示例14: 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

示例15: 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->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('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->isGranted('ROLE_USER')) {
         $Customer = $app->user();
         $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:nanasess,项目名称:nagoya-eccube-study,代码行数:43,代码来源:ProductController.php


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