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