Skip to content

Commit

Permalink
Merge pull request #1 from 13watanabe/add-maintenance-mode
Browse files Browse the repository at this point in the history
Add maintenance mode
  • Loading branch information
kanako-kina authored Nov 20, 2018
2 parents 99a126b + cdd63ba commit f7a8ddb
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(SystemService $systemService) {
* メンテナンス管理ページを表示
*
* @Route("/%eccube_admin_route%/content/maintenance", name="admin_content_maintenance")
* @Template("@admin/Content/maintenance.twig")*
* @Template("@admin/Content/maintenance.twig")
*/
public function index(Request $request)
{
Expand All @@ -53,6 +53,8 @@ public function index(Request $request)
$isMaintenace = $this->systemService->isMaintenanceMode();

$this->addSuccess(($isMaintenace) ? 'admin.content.maintenance_switch__on_message' : 'admin.content.maintenance_switch__off_message', 'admin');

$this->redirectToRoute('admin_content_maintenance');
}

return [
Expand Down
34 changes: 31 additions & 3 deletions src/Eccube/Controller/Admin/Store/OwnerStoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
use Knp\Component\Pager\Paginator;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;

Expand Down Expand Up @@ -260,8 +262,16 @@ public function doConfirm(Request $request, $id)
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function apiInstall(Request $request)
public function apiInstall(Request $request, EventDispatcherInterface $dispatcher)
{
// .maintenanceファイルを設置
$this->systemService->switchMaintenance(true);

// TERMINATE時のイベントを設定
$dispatcher->addListener(KernelEvents::TERMINATE, function () {
// .maintenanceファイルを削除
$this->systemService->switchMaintenance();
});
$this->isTokenValid();

$this->cacheUtil->clearCache();
Expand Down Expand Up @@ -290,8 +300,17 @@ public function apiInstall(Request $request)
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function apiUninstall(Plugin $Plugin)
public function apiUninstall(Plugin $Plugin, EventDispatcherInterface $dispatcher)
{
// .maintenanceファイルを設置
$this->systemService->switchMaintenance(true);

// TERMINATE時のイベントを設定
$dispatcher->addListener(KernelEvents::TERMINATE, function () {
// .maintenanceファイルを削除
$this->systemService->switchMaintenance();
});

$this->isTokenValid();

$this->cacheUtil->clearCache();
Expand Down Expand Up @@ -337,8 +356,17 @@ public function apiUninstall(Plugin $Plugin)
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function apiUpgrade(Request $request)
public function apiUpgrade(Request $request, EventDispatcherInterface $dispatcher)
{
// .maintenanceファイルを設置
$this->systemService->switchMaintenance(true);

// TERMINATE時のイベントを設定
$dispatcher->addListener(KernelEvents::TERMINATE, function () {
// .maintenanceファイルを削除
$this->systemService->switchMaintenance();
});

$this->isTokenValid();

$this->cacheUtil->clearCache();
Expand Down
11 changes: 1 addition & 10 deletions src/Eccube/Controller/Admin/Store/PluginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,8 @@ public function disable(Request $request, Plugin $Plugin, CacheUtil $cacheUtil,
*
* @throws \Exception
*/
public function uninstall(Plugin $Plugin, CacheUtil $cacheUtil, EventDispatcherInterface $dispatcher)
public function uninstall(Plugin $Plugin, CacheUtil $cacheUtil)
{
die();
// .maintenanceファイルを設置
$this->systemService->switchMaintenance(true);

// TERMINATE時のイベントを設定
$dispatcher->addListener(KernelEvents::TERMINATE, function () {
// .maintenanceファイルを削除
$this->systemService->switchMaintenance();
});

$this->isTokenValid();

Expand Down
4 changes: 2 additions & 2 deletions src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ admin.content.maintenance__card_title: メンテナンスモード
admin.content.maintenance_message: |
メンテナンスモードを有効にすると、SHOPの機能を一時的に停止し、管理画面のみアクセス可能な状態となります。
※プラグインのインストール/有効/無効/削除時には、自動的にメンテナンスモードに切り替わります。
admin.content.maintenance_switch__on: 有効
admin.content.maintenance_switch__off: 無効
admin.content.maintenance_switch__on: 有効にする
admin.content.maintenance_switch__off: 無効にする
admin.content.maintenance_switch__on_message: メンテナンスモードを有効にしました。
admin.content.maintenance_switch__off_message: メンテナンスモードを無効にしました。

Expand Down
8 changes: 0 additions & 8 deletions src/Eccube/Resource/template/admin/Content/maintenance.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ file that was distributed with this source code.
{% block title %}{{ 'admin.content.maintenance_management'|trans }}{% endblock %}
{% block sub_title %}{{ 'admin.content.contents_management'|trans }}{% endblock %}

{% block stylesheet %}
<style type="text/css">
li.list-group-item {
z-index: inherit !important;
}
</style>
{% endblock %}

{% block main %}
<form method="post" action="{{ url('admin_content_maintenance') }}">
{{ form_widget(form._token) }}
Expand Down

0 comments on commit f7a8ddb

Please sign in to comment.