Skip to content

Commit

Permalink
Merge pull request #5399 from sai-gillingham/issue/5304
Browse files Browse the repository at this point in the history
改正商取引法の施行に伴うECカート「最終確認画面」表示項目の変更[#5304]について
  • Loading branch information
chihiro-adachi authored Jun 29, 2022
2 parents 900ef73 + da9ff65 commit 28fc111
Show file tree
Hide file tree
Showing 26 changed files with 1,262 additions and 103 deletions.
3 changes: 1 addition & 2 deletions app/config/eccube/packages/eccube_nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ parameters:
url: admin_setting_shop
shop_tradelaw:
name: admin.setting.shop.tradelaw_setting
url: admin_content_page_edit
param: { id: !php/const Eccube\Entity\Page::TRADELAW_PAGE_ID, return: tradelaw }
url: admin_setting_shop_tradelaw
shop_agreement:
name: admin.setting.shop.agreement_setting
url: admin_content_page_edit
Expand Down
20 changes: 0 additions & 20 deletions codeception/acceptance/EA07BasicinfoCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,26 +455,6 @@ public function basicinfo_ポイント設定_無効(AcceptanceTester $I)
$I->assertEquals('0', $I->grabTextFrom(OrderEditPage::$加算ポイント));
}
public function basicinfo_特定商取引法(AcceptanceTester $I)
{
$I->wantTo('EA0702-UC01-T01 特定商取引法の設定');

PageManagePage::go($I);
$I->click(['xpath' => '//a[contains(text(), "特定商取引")]']);

$test_text = uniqid('テストテキスト');
$before = PageEditPage::at($I)->出力_内容();
$after = preg_replace('/(<\/h1>.*?\n)/', "</h1>{$test_text}\n", $before);
PageEditPage::at($I)
->入力_内容($after)
->登録();

$I->see('保存しました', PageEditPage::$登録完了メッセージ);

$I->amOnPage('/help/tradelaw');
$I->see($test_text);
}

public function basicinfo_会員規約(AcceptanceTester $I)
{
$I->wantTo('EA0703-UC01-T01 会員規約の設定');
Expand Down
86 changes: 86 additions & 0 deletions src/Eccube/Controller/Admin/Setting/Shop/TradeLawController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Eccube\Controller\Admin\Setting\Shop;

use Eccube\Controller\AbstractController;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Form\Type\Admin\OrderStatusSettingType;
use Eccube\Form\Type\Admin\TradeLawType;
use Eccube\Form\Type\Front\ForgotType;
use Eccube\Repository\TradeLawRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;

class TradeLawController extends AbstractController
{
protected TradeLawRepository $tradeLawRepository;

/**
* @param TradeLawRepository $tradeLawRepository
*/
public function __construct(
TradeLawRepository $tradeLawRepository
) {
$this->tradeLawRepository = $tradeLawRepository;
}

/**
* 特定商取引法設定の初期表示・登録
*
* @Route("/%eccube_admin_route%/setting/shop/tradelaw", name="admin_setting_shop_tradelaw", methods={"GET", "POST"})
* @Template("@admin/Setting/Shop/tradelaw.twig")
* @param Request $request
*/
public function index(Request $request)
{
$tradeLawDetails = $this->tradeLawRepository->findBy([], ['sortNo' => 'ASC']);
$builder = $this->formFactory->createBuilder();
$builder
->add(
'TradeLaws',
CollectionType::class,
[
'entry_type' => TradeLawType::class,
'data' => $tradeLawDetails,
]
);
$form = $builder->getForm();
$form->handleRequest($request);

$event = new EventArgs(
[
'TradeLaw' => $tradeLawDetails,
],
$request
);



$form = $builder->getForm();
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
foreach ($form['TradeLaws'] as $child) {
$TradeLaw = $child->getData();
$this->entityManager->persist($TradeLaw);
}
$this->entityManager->flush();

$this->addSuccess('admin.common.save_complete', 'admin');

$this->eventDispatcher->dispatch($event, EccubeEvents::ADMIN_SETTING_SHOP_TRADE_LAW_POST_COMPLETE);

return $this->redirectToRoute('admin_setting_shop_tradelaw');
}

$this->eventDispatcher->dispatch($event, EccubeEvents::ADMIN_SETTING_SHOP_TRADE_LAW_INDEX_COMPLETE);

return [
'form' => $form->createView(),
'tradeLawDetails' => $tradeLawDetails
];
}
}
11 changes: 0 additions & 11 deletions src/Eccube/Controller/HelpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ public function __construct()
{
}

/**
* 特定商取引法.
*
* @Route("/help/tradelaw", name="help_tradelaw", methods={"GET"})
* @Template("Help/tradelaw.twig")
*/
public function tradelaw()
{
return [];
}

/**
* ご利用ガイド.
*
Expand Down
19 changes: 18 additions & 1 deletion src/Eccube/Controller/ShoppingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Eccube\Form\Type\Shopping\CustomerAddressType;
use Eccube\Form\Type\Shopping\OrderType;
use Eccube\Repository\OrderRepository;
use Eccube\Repository\TradeLawRepository;
use Eccube\Service\CartService;
use Eccube\Service\MailService;
use Eccube\Service\OrderHelper;
Expand Down Expand Up @@ -67,18 +68,25 @@ class ShoppingController extends AbstractShoppingController
*/
protected $serviceContainer;

/**
* @var TradeLawRepository
*/
protected TradeLawRepository $tradeLawRepository;

public function __construct(
CartService $cartService,
MailService $mailService,
OrderRepository $orderRepository,
OrderHelper $orderHelper,
ContainerInterface $serviceContainer
ContainerInterface $serviceContainer,
TradeLawRepository $tradeLawRepository
) {
$this->cartService = $cartService;
$this->mailService = $mailService;
$this->orderRepository = $orderRepository;
$this->orderHelper = $orderHelper;
$this->serviceContainer = $serviceContainer;
$this->tradeLawRepository = $tradeLawRepository;
}

/**
Expand Down Expand Up @@ -145,11 +153,14 @@ public function index(PurchaseFlow $cartPurchaseFlow)
$this->entityManager->flush();
}

$activeTradeLaws = $this->tradeLawRepository->findBy(['displayOrderScreen' => true], ['sortNo' => 'ASC']);

$form = $this->createForm(OrderType::class, $Order);

return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand Down Expand Up @@ -230,11 +241,14 @@ public function redirectTo(Request $request, RouterInterface $router)
}
}

$activeTradeLaws = $this->tradeLawRepository->findBy(['displayOrderScreen' => true], ['sortNo' => 'ASC']);

log_info('[リダイレクト] フォームエラーのため, 注文手続き画面を表示します.', [$Order->getId()]);

return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand Down Expand Up @@ -266,6 +280,7 @@ public function confirm(Request $request)
return $this->redirectToRoute('shopping_error');
}

$activeTradeLaws = $this->tradeLawRepository->findBy(['displayOrderScreen' => true], ['sortNo' => 'ASC']);
$form = $this->createForm(OrderType::class, $Order);
$form->handleRequest($request);

Expand Down Expand Up @@ -311,6 +326,7 @@ public function confirm(Request $request)
return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand All @@ -325,6 +341,7 @@ public function confirm(Request $request)
return [
'form' => $form->createView(),
'Order' => $Order,
'activeTradeLaws' => $activeTradeLaws
];
}

Expand Down
46 changes: 46 additions & 0 deletions src/Eccube/Controller/TradeLawController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Controller;

use Eccube\Repository\TradeLawRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;

class TradeLawController extends AbstractController
{
/** @var TradeLawRepository */
protected $tradeLawRepository;

/**
* @param TradeLawRepository $tradeLawRepository
*/
public function __construct(
TradeLawRepository $tradeLawRepository
) {
$this->tradeLawRepository = $tradeLawRepository;
}

/**
* @Route("/help/tradelaw", name="help_tradelaw", methods={"GET"})
* @Template("Help/tradelaw.twig")
*/
public function index()
{
$tradelaws = $this->tradeLawRepository->findBy([], ['sortNo' => 'ASC']);

return [
'tradelaws' => $tradelaws
];
}
}
Loading

0 comments on commit 28fc111

Please sign in to comment.