From dd255dd27bcbf8263b5e2d68503f42dcdc7295b9 Mon Sep 17 00:00:00 2001 From: ryuring Date: Tue, 27 Feb 2024 14:44:03 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=86=E3=83=B3=E3=83=84?= =?UTF-8?q?=E3=83=84=E3=83=AA=E3=83=BC=E3=82=92=E3=83=AA=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=80=81URL?= =?UTF-8?q?=E3=81=8C=E7=A9=BA=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=86=E5=95=8F=E9=A1=8C=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Admin/UtilitiesController.php | 3 ++- .../src/Model/Table/ContentsTable.php | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/baser-core/src/Controller/Admin/UtilitiesController.php b/plugins/baser-core/src/Controller/Admin/UtilitiesController.php index 9ee1105ddd..998a5561ac 100644 --- a/plugins/baser-core/src/Controller/Admin/UtilitiesController.php +++ b/plugins/baser-core/src/Controller/Admin/UtilitiesController.php @@ -13,6 +13,7 @@ use BaserCore\Error\BcException; use BaserCore\Service\Admin\UtilitiesAdminServiceInterface; +use BaserCore\Service\UtilitiesService; use BaserCore\Service\UtilitiesServiceInterface; use BaserCore\Utility\BcUtil; use BaserCore\Annotation\UnitTest; @@ -193,7 +194,7 @@ public function log_maintenance(UtilitiesAdminServiceInterface $service, string /** * コンテンツ管理のツリー構造をリセットする - * @param UtilitiesServiceInterface $service + * @param UtilitiesServiceInterface|UtilitiesService $service * @checked * @noTodo * @unitTest diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php index e79feff524..2e1c91adda 100644 --- a/plugins/baser-core/src/Model/Table/ContentsTable.php +++ b/plugins/baser-core/src/Model/Table/ContentsTable.php @@ -1313,10 +1313,9 @@ public function resetTree() $this->removeBehavior('Tree'); $this->updatingRelated = false; - $beforeSaveListeners = $this->getEventManager()->listeners('Model.beforeSave'); - $this->getEventManager()->off('Model.beforeSave', $beforeSaveListeners); - $afterSaveListeners = $this->getEventManager()->listeners('Model.afterSave'); - $this->getEventManager()->off('Model.afterSave', $afterSaveListeners); + $eventManager = $this->getEventManager(); + $beforeSaveListeners = BcUtil::offEvent($eventManager, 'Model.beforeSave'); + $afterSaveListeners = BcUtil::offEvent($eventManager, 'Model.afterSave'); $this->getConnection()->begin(); $result = true; @@ -1343,7 +1342,7 @@ public function resetTree() $content->rght = $count; $content->level = $siteRoot->level + 1; $content->parent_id = $siteRoot->id; - if (!$this->save($content, false)) $result = false; + if (!$this->save($content)) $result = false; } } if ($siteRoot->id == 1) { @@ -1362,15 +1361,14 @@ public function resetTree() $this->addBehavior('Tree'); $this->updatingRelated = true; - $this->getEventManager()->on('Model.beforeSave', $beforeSaveListeners); - $this->getEventManager()->on('Model.afterSave', $afterSaveListeners); + BcUtil::onEvent($eventManager, 'Model.beforeSave', $beforeSaveListeners); + BcUtil::onEvent($eventManager, 'Model.afterSave', $afterSaveListeners); $contents = $this->find()->order(['lft'])->all(); if ($contents) { foreach($contents as $content) { - // バリデーションをオンにする事で同名コンテンツを強制的にリネームする - // beforeValidate でリネーム処理を入れている為 - // (第二引数を false に設定しない) + // setDirty を利用して同名コンテンツを強制的にリネームする + $content->setDirty('name', true); if (!$this->save($content)) $result = false; } }