-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from KenTanaka/main
正式ブランチへの最新版コミット
- Loading branch information
Showing
37 changed files
with
3,151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?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 Plugin\TwoFactorAuthCustomer42\Controller\Admin; | ||
|
||
use Eccube\Repository\BaseInfoRepository; | ||
use Eccube\Controller\AbstractController; | ||
use Plugin\TwoFactorAuthCustomer42\Form\Type\SmsConfigType; | ||
use Plugin\TwoFactorAuthCustomer42\Repository\SmsConfigRepository; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Class SmsController | ||
*/ | ||
class ConfigController extends AbstractController | ||
{ | ||
/** | ||
* @var BaseInfoRepository | ||
*/ | ||
protected $baseInfoRepository; | ||
|
||
/** | ||
* @var SmsConfigRepository | ||
*/ | ||
private $smsConfigRepository; | ||
|
||
/** | ||
* SmsConfigController constructor. | ||
* | ||
*/ | ||
public function __construct(BaseInfoRepository $baseInfoRepository, SmsConfigRepository $smsConfigRepository) | ||
{ | ||
$this->baseInfoRepository = $baseInfoRepository; | ||
$this->smsConfigRepository = $smsConfigRepository; | ||
} | ||
|
||
/** | ||
* @Route("/%eccube_admin_route%/two_factor_auth_customer42/config", name="two_factor_auth_customer42_admin_config") | ||
* @Template("TwoFactorAuthCustomer42/Resource/template/admin/config.twig") | ||
* | ||
* @param Request $request | ||
* | ||
* @return array | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
// 設定情報、フォーム情報を取得 | ||
$SmsConfig = $this->smsConfigRepository->findOne(); | ||
$form = $this->createForm(SmsConfigType::class, $SmsConfig); | ||
$form->handleRequest($request); | ||
|
||
// 設定画面で登録ボタンが押されたらこの処理を行う | ||
if ($form->isSubmitted() && $form->isValid()) { | ||
// フォームの入力データを取得 | ||
$SmsConfig = $form->getData(); | ||
|
||
// フォームの入力データを保存 | ||
$this->entityManager->persist($SmsConfig); | ||
$this->entityManager->flush($SmsConfig); | ||
|
||
// 完了メッセージを表示 | ||
log_info('config', ['status' => 'Success']); | ||
$this->addSuccess('プラグインの設定を保存しました。', 'admin'); | ||
|
||
// 設定画面にリダイレクト | ||
return $this->redirectToRoute('two_factor_auth_customer42_admin_config'); | ||
} | ||
|
||
return [ | ||
'SmsConfig' => $SmsConfig, | ||
'form' => $form->createView(), | ||
]; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.