umebius さん
ありがとうございます。
src/Eccube/Controller/ShoppingController.php
src/Eccube/Resource/template/default/Shopping/login.twig
ベースに作成したらできました。
以下メモです。
Controller側
//以下追加
use Eccube\Form\Type\Front\CustomerLoginType;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
//非ログイン時ログインフォーム設置用追加
public function index(Request $request, AuthenticationUtils $authenticationUtils)
//public function index(Request $request)
{
// カートを取得して明細の正規化を実行
$Carts = $this->cartService->getCarts();
$this->execPurchaseFlow($Carts);
// TODO itemHolderから取得できるように
$least = [];
$quantity = [];
$isDeliveryFree = [];
$totalPrice = 0;
$totalQuantity = 0;
foreach ($Carts as $Cart) {
$quantity[$Cart->getCartKey()] = 0;
$isDeliveryFree[$Cart->getCartKey()] = false;
if ($this->baseInfo->getDeliveryFreeQuantity()) {
if ($this->baseInfo->getDeliveryFreeQuantity() > $Cart->getQuantity()) {
$quantity[$Cart->getCartKey()] = $this->baseInfo->getDeliveryFreeQuantity()-$Cart->getQuantity();
} else {
$isDeliveryFree[$Cart->getCartKey()] = true;
}
}
if ($this->baseInfo->getDeliveryFreeAmount()) {
if (!$isDeliveryFree[$Cart->getCartKey()] && $this->baseInfo->getDeliveryFreeAmount() <= $Cart->getTotalPrice()) {
$isDeliveryFree[$Cart->getCartKey()] = true;
} else {
$least[$Cart->getCartKey()] = $this->baseInfo->getDeliveryFreeAmount() - $Cart->getTotalPrice();
}
}
$totalPrice += $Cart->getTotalPrice();
$totalQuantity += $Cart->getQuantity();
}
// カートが分割された時のセッション情報を削除
$request->getSession()->remove(OrderHelper::SESSION_CART_DIVIDE_FLAG);
//非ログイン時ログインフォーム設置用追加
/* @var $form \Symfony\Component\Form\FormInterface */
$builder = $this->formFactory->createNamedBuilder('', CustomerLoginType::class);
$builder->get('login_memory')->setData((bool) $request->getSession()->get('_security.login_memory'));
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$Customer = $this->getUser();
if ($Customer instanceof Customer) {
$builder->get('login_email')->setData($Customer->getEmail());
}
}
$event = new EventArgs(['builder' => $builder,],$request);
$this->eventDispatcher->dispatch(EccubeEvents::FRONT_MYPAGE_MYPAGE_LOGIN_INITIALIZE, $event);
$form = $builder->getForm();
//非ログイン時ログインフォーム設置用追加
return [
'totalPrice' => $totalPrice,
'totalQuantity' => $totalQuantity,
// 空のカートを削除し取得し直す
'Carts' => $this->cartService->getCarts(true),
'least' => $least,
'quantity' => $quantity,
'is_delivery_free' => $isDeliveryFree,
//非ログイン時ログインフォーム設置用追加
'error' => $authenticationUtils->getLastAuthenticationError(),
'form' => $form->createView(),
//非ログイン時ログインフォーム設置用追加
];
}
------------------twig側----------------------
<form name="shopping_login" id="shopping_login" method="post" action="{{ url('mypage_login') }}">
</form>
部分コピペで動きます。