Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ページ管理の編集対象に会員登録(確認ページ)を加える #4428 #4433

Merged
merged 9 commits into from
Dec 2, 2020
75 changes: 75 additions & 0 deletions app/DoctrineMigrations/Version20201127000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

declare(strict_types=1);

/*
* 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 DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201127000000 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$count = $this->connection->fetchColumn("SELECT COUNT(*) FROM dtb_page WHERE url = 'entry_confirm'");
if ($count > 0) {
return;
}
$pageId = $this->connection->fetchColumn('SELECT MAX(id) FROM dtb_page');
$sortNo = $this->connection->fetchColumn('SELECT MAX(sort_no) FROM dtb_page_layout');

$pageId++;
$this->addSql("INSERT INTO dtb_page (
id, master_page_id, page_name, url, file_name, edit_type, create_date, update_date, meta_robots, discriminator_type
) VALUES(
$pageId, 18, '会員登録(確認ページ)', 'entry_confirm', 'Entry/confirm', 3, '2020-01-12 01:15:03', '2020-01-12 01:15:03', 'noindex', 'page'
)");

$sortNo++;
$this->addSql("INSERT INTO dtb_page_layout (page_id, layout_id, sort_no, discriminator_type) VALUES ($pageId, 2, $sortNo, 'pagelayout')");

$pageId++;
$this->addSql("INSERT INTO dtb_page (
id, master_page_id, page_name, url, file_name, edit_type, create_date, update_date, meta_robots, discriminator_type
) VALUES(
$pageId, 12, 'MYページ/退会手続き(確認ページ)', 'mypage_withdraw_confirm', 'Mypage/withdraw_confirm', 3, '2020-01-12 01:15:03', '2020-01-12 01:15:03', 'noindex', 'page'
)");

$sortNo++;
$this->addSql("INSERT INTO dtb_page_layout (page_id, layout_id, sort_no, discriminator_type) VALUES ($pageId, 2, $sortNo, 'pagelayout')");

$pageId++;
$this->addSql("INSERT INTO dtb_page (
id, master_page_id, page_name, url, file_name, edit_type, create_date, update_date, meta_robots, discriminator_type
) VALUES(
$pageId, 16, 'お問い合わせ(確認ページ)', 'contact_confirm', 'Contact/confirm', 3, '2020-01-12 01:15:03', '2020-01-12 01:15:03', 'noindex', 'page'
)");

$sortNo++;
$this->addSql("INSERT INTO dtb_page_layout (page_id, layout_id, sort_no, discriminator_type) VALUES ($pageId, 2, $sortNo, 'pagelayout')");

if ($this->platform->getName() === 'postgresql') {
$this->addSql("SELECT setval('dtb_page_id_seq', $pageId)");
}
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs

}
}
2 changes: 1 addition & 1 deletion src/Eccube/Controller/Admin/Content/LayoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function edit(Request $request, $id = null, $previewPageId = null, CacheU
throw new NotFoundHttpException();
}

if ($Page->getEditType() == \Eccube\Entity\Page::EDIT_TYPE_DEFAULT) {
if ($Page->getEditType() >= \Eccube\Entity\Page::EDIT_TYPE_DEFAULT) {
if ($Page->getUrl() === 'product_detail') {
$product = $this->productRepository->findOneBy(['Status' => ProductStatus::DISPLAY_SHOW]);
if (is_null($product)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Eccube/Controller/Admin/Content/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function edit(Request $request, $id = null, Environment $twig, RouterInte
$namespace = '@user_data/';
if ($id) {
// 編集不可ページはURL、ページ名、ファイル名を保持
if ($Page->getEditType() == Page::EDIT_TYPE_DEFAULT) {
if ($Page->getEditType() >= Page::EDIT_TYPE_DEFAULT) {
$isUserDataPage = false;
$namespace = '';
$PrevPage = clone $Page;
Expand Down Expand Up @@ -245,6 +245,7 @@ public function edit(Request $request, $id = null, Environment $twig, RouterInte
'form' => $form->createView(),
'page_id' => $Page->getId(),
'is_user_data_page' => $isUserDataPage,
'is_confirm_page' => $Page->getEditType() == Page::EDIT_TYPE_DEFAULT_CONFIRM,
'template_path' => $templatePath,
'url' => $url,
];
Expand Down
13 changes: 12 additions & 1 deletion src/Eccube/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Form\Type\Front\ContactType;
use Eccube\Repository\PageRepository;
use Eccube\Service\MailService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -29,21 +30,30 @@ class ContactController extends AbstractController
*/
protected $mailService;

/**
* @var PageRepository
*/
private $pageRepository;

/**
* ContactController constructor.
*
* @param MailService $mailService
* @param PageRepository $pageRepository
*/
public function __construct(
MailService $mailService)
MailService $mailService,
PageRepository $pageRepository)
{
$this->mailService = $mailService;
$this->pageRepository = $pageRepository;
}

/**
* お問い合わせ画面.
*
* @Route("/contact", name="contact")
* @Route("/contact", name="contact_confirm")
* @Template("Contact/index.twig")
*/
public function index(Request $request)
Expand Down Expand Up @@ -86,6 +96,7 @@ public function index(Request $request)
case 'confirm':
return $this->render('Contact/confirm.twig', [
'form' => $form->createView(),
'Page' => $this->pageRepository->getPageByRoute('contact_confirm')
]);

case 'complete':
Expand Down
12 changes: 11 additions & 1 deletion src/Eccube/Controller/EntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\CustomerRepository;
use Eccube\Repository\Master\CustomerStatusRepository;
use Eccube\Repository\PageRepository;
use Eccube\Service\MailService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -76,6 +77,11 @@ class EntryController extends AbstractController
*/
protected $cartService;

/**
* @var PageRepository
*/
protected $pageRepository;

/**
* EntryController constructor.
*
Expand All @@ -96,7 +102,8 @@ public function __construct(
CustomerRepository $customerRepository,
EncoderFactoryInterface $encoderFactory,
ValidatorInterface $validatorInterface,
TokenStorageInterface $tokenStorage
TokenStorageInterface $tokenStorage,
PageRepository $pageRepository
) {
$this->customerStatusRepository = $customerStatusRepository;
$this->mailService = $mailService;
Expand All @@ -106,12 +113,14 @@ public function __construct(
$this->recursiveValidator = $validatorInterface;
$this->tokenStorage = $tokenStorage;
$this->cartService = $cartService;
$this->pageRepository = $pageRepository;
}

/**
* 会員登録画面.
*
* @Route("/entry", name="entry")
* @Route("/entry", name="entry_confirm")
* @Template("Entry/index.twig")
*/
public function index(Request $request)
Expand Down Expand Up @@ -152,6 +161,7 @@ public function index(Request $request)
'Entry/confirm.twig',
[
'form' => $form->createView(),
'Page' => $this->pageRepository->getPageByRoute('entry_confirm')
]
);

Expand Down
13 changes: 12 additions & 1 deletion src/Eccube/Controller/Mypage/WithdrawController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Repository\Master\CustomerStatusRepository;
use Eccube\Repository\PageRepository;
use Eccube\Service\CartService;
use Eccube\Service\MailService;
use Eccube\Service\OrderHelper;
Expand Down Expand Up @@ -55,6 +56,11 @@ class WithdrawController extends AbstractController
*/
private $orderHelper;

/**
* @var PageRepository
*/
private $pageRepository;

/**
* WithdrawController constructor.
*
Expand All @@ -63,25 +69,29 @@ class WithdrawController extends AbstractController
* @param TokenStorageInterface $tokenStorage
* @param CartService $cartService
* @param OrderHelper $orderHelper
* @param PageRepository $pageRepository
*/
public function __construct(
MailService $mailService,
CustomerStatusRepository $customerStatusRepository,
TokenStorageInterface $tokenStorage,
CartService $cartService,
OrderHelper $orderHelper
OrderHelper $orderHelper,
PageRepository $pageRepository
) {
$this->mailService = $mailService;
$this->customerStatusRepository = $customerStatusRepository;
$this->tokenStorage = $tokenStorage;
$this->cartService = $cartService;
$this->orderHelper = $orderHelper;
$this->pageRepository = $pageRepository;
}

/**
* 退会画面.
*
* @Route("/mypage/withdraw", name="mypage_withdraw")
* @Route("/mypage/withdraw", name="mypage_withdraw_confirm")
* @Template("Mypage/withdraw.twig")
*/
public function index(Request $request)
Expand Down Expand Up @@ -109,6 +119,7 @@ public function index(Request $request)
'Mypage/withdraw_confirm.twig',
[
'form' => $form->createView(),
'Page' => $this->pageRepository->getPageByRoute('mypage_withdraw_confirm')
]
);

Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Entity/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Page extends \Eccube\Entity\AbstractEntity
const EDIT_TYPE_USER = 0;
const EDIT_TYPE_PREVIEW = 1;
const EDIT_TYPE_DEFAULT = 2;
const EDIT_TYPE_DEFAULT_CONFIRM = 3;

// 特定商取引法ページID
const TRADELAW_PAGE_ID = 21;
Expand Down
9 changes: 8 additions & 1 deletion src/Eccube/Form/Type/Admin/MainEditType.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->setParameter('page_id', $Page->getId());
}

//確認ページの編集ページ存在している場合
if ($Page->getEditType() == Page::EDIT_TYPE_DEFAULT_CONFIRM && $Page->getMasterPage()) {
$qb
->andWhere('p.id <> :master_page_id')
->setParameter('master_page_id', $Page->getMasterPage()->getId());
}

$count = $qb->getQuery()->getSingleScalarResult();
if ($count > 0) {
$form['url']->addError(new FormError(trans('admin.content.page_url_exists')));
Expand Down Expand Up @@ -253,7 +260,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$qb->select('count(p)')
->from('Eccube\\Entity\\Page', 'p')
->where('p.file_name = :file_name')
->andWhere('p.edit_type = :edit_type')
->andWhere('p.edit_type >= :edit_type')
->setParameter('file_name', $Page->getFileName())
->setParameter('edit_type', Page::EDIT_TYPE_DEFAULT);

Expand Down
5 changes: 3 additions & 2 deletions src/Eccube/Repository/PageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ public function getPageList($where = null, $parameters = [])
{
$qb = $this->createQueryBuilder('p')
->andWhere('p.id <> 0')
->andWhere('p.MasterPage is null')
->orderBy('p.id', 'ASC');
->andWhere('(p.MasterPage is null OR p.edit_type = :edit_type)')
->orderBy('p.id', 'ASC')
->setParameter('edit_type', Page::EDIT_TYPE_DEFAULT_CONFIRM);
if (!is_null($where)) {
$qb->andWhere($where);
foreach ($parameters as $key => $val) {
Expand Down
5 changes: 4 additions & 1 deletion src/Eccube/Resource/doctrine/import_csv/en/dtb_page.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ id,page_name,url,file_name,edit_type,author,description,keyword,create_date,upda
<meta property=""product:price:amount"" content=""{{ Product.getPrice02IncTaxMin }}""/>
<meta property=""product:price:currency"" content=""{{ eccube_config.currency }}""/>
<meta property=""product:product_link"" content=""{{ url('product_detail', {'id': Product.id}) }}""/>
<meta property=""product:retailer_title"" content=""{{ BaseInfo.shop_name }}""/>"
<meta property=""product:retailer_title"" content=""{{ Product.name }}""/>"
4,My Account,mypage,Mypage/index,2,,,,2017-03-07 10:14:52,2017-03-07 10:14:52,noindex,,page,
5,My Account / Edit Customer Info (Form),mypage_change,Mypage/change,2,,,,2017-03-07 10:14:52,2017-03-07 10:14:52,noindex,,page,
6,My Account / Edit Customer Info (Thank-you),mypage_change_complete,Mypage/change_complete,2,,,,2017-03-07 10:14:52,2017-03-07 10:14:52,noindex,,page,
Expand Down Expand Up @@ -47,3 +47,6 @@ id,page_name,url,file_name,edit_type,author,description,keyword,create_date,upda
42,Shopping / Change Delivery Address,shopping_shipping_edit_change,Shopping/index,2,,,,2017-03-07 01:15:03,2017-03-07 01:15:03,noindex,,page,
44,My Account / Edit Delivery Address,mypage_delivery_edit,Mypage/delivery_edit,2,,,,2017-03-07 01:15:05,2017-03-07 01:15:05,noindex,8,page,
45,Shopping / Review,shopping_confirm,Shopping/confirm,2,,,,2017-03-07 01:15:03,2017-03-07 01:15:03,noindex,,page,
46,Registration (Form) Review,entry_confirm,Entry/confirm,3,,,,2020-01-12 01:15:03,2020-01-12 01:15:03,noindex,18,page,
47,My Account / Membership Cancellation (Form) Review,mypage_withdraw_confirm,Mypage/withdraw_confirm,3,,,,2020-01-12 10:14:52,2020-01-12 10:14:52,noindex,12,page,
48,Inquiry (Form) Review,contact_confirm,Contact/confirm,3,,,,2020-01-12 10:14:52,2020-01-12 10:14:52,noindex,16,page,
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ page_id,layout_id,sort_no,discriminator_type
"38","2","39","pagelayout"
"44","2","40","pagelayout"
"45","2","41","pagelayout"
"46","2","42","pagelayout"
"47","2","43","pagelayout"
"48","2","44","pagelayout"
3 changes: 3 additions & 0 deletions src/Eccube/Resource/doctrine/import_csv/ja/dtb_page.csv
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ id,page_name,url,file_name,edit_type,author,description,keyword,create_date,upda
"42","商品購入/遷移","shopping_redirect_to","Shopping/index","2",,,,"2017-03-07 01:15:03","2017-03-07 01:15:03","noindex",,"page",
"44","MYページ/お届け先編集","mypage_delivery_edit","Mypage/delivery_edit","2",,,,"2017-03-07 01:15:05","2017-03-07 01:15:05","noindex",8,"page",
"45","商品購入/ご注文確認","shopping_confirm","Shopping/confirm","2",,,,"2017-03-07 01:15:03","2017-03-07 01:15:03","noindex",,"page",
"46","会員登録(確認ページ)","entry_confirm","Entry/confirm","3",,,,"2020-01-12 01:15:03","2020-01-12 01:15:03","noindex",18,"page",
"47","MYページ/退会手続き(確認ページ)","mypage_withdraw_confirm","Mypage/withdraw_confirm","3",,,,"2020-01-12 10:14:52","2020-01-12 10:14:52","noindex",12,"page",
"48","お問い合わせ(確認ページ)","contact_confirm","Contact/confirm","3",,,,"2020-01-12 10:14:52","2020-01-12 10:14:52","noindex",16,"page",
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ page_id,layout_id,sort_no,discriminator_type
"38","2","39","pagelayout"
"44","2","40","pagelayout"
"45","2","41","pagelayout"
"46","2","42","pagelayout"
"47","2","43","pagelayout"
"48","2","44","pagelayout"
Loading