From bf0dd9a4f520eb5d13812c1c6c242125be5bf002 Mon Sep 17 00:00:00 2001 From: ryuring Date: Tue, 27 Feb 2024 19:26:17 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=82=B0=E3=83=AB=E3=83=BC=E3=83=97=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2=E3=81=A7=E3=80=81url=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89=E3=81=8C=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/Model/Table/PermissionsTable.php | 5 +++-- .../tests/Scenario/PermissionGroupsScenario.php | 3 +++ .../Controller/Admin/PermissionGroupsControllerTest.php | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/baser-core/src/Model/Table/PermissionsTable.php b/plugins/baser-core/src/Model/Table/PermissionsTable.php index ed50aec353..a0b26be9a1 100644 --- a/plugins/baser-core/src/Model/Table/PermissionsTable.php +++ b/plugins/baser-core/src/Model/Table/PermissionsTable.php @@ -158,8 +158,9 @@ public function validationPlain($validator) public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options) { $data = $event->getData(); - if (preg_match('/^[^\/]/is', $data["entity"]->get("url"))) { - $data["entity"]->set("url", '/' . $data["entity"]->get("url")); + $url = $data["entity"]->get("url"); + if ($url && preg_match('/^[^\/]/is', $url)) { + $data["entity"]->set("url", '/' . $url); } return true; } diff --git a/plugins/baser-core/tests/Scenario/PermissionGroupsScenario.php b/plugins/baser-core/tests/Scenario/PermissionGroupsScenario.php index e928b72517..450e8b3715 100644 --- a/plugins/baser-core/tests/Scenario/PermissionGroupsScenario.php +++ b/plugins/baser-core/tests/Scenario/PermissionGroupsScenario.php @@ -53,6 +53,7 @@ public function load(...$args) ])->persist(); PermissionFactory::make([ + 'id' => 1, 'no' => 1, 'sort' => 1, 'name' => 'システム管理', @@ -67,6 +68,7 @@ public function load(...$args) ])->persist(); PermissionFactory::make([ + 'id' => 2, 'no' => 1, 'sort' => 1, 'name' => 'よく使う項目', @@ -81,6 +83,7 @@ public function load(...$args) ])->persist(); PermissionFactory::make([ + 'id' => 3, 'no' => 1, 'sort' => 1, 'name' => 'ページ管理', diff --git a/plugins/baser-core/tests/TestCase/Controller/Admin/PermissionGroupsControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/Admin/PermissionGroupsControllerTest.php index 049a124714..77b4437465 100644 --- a/plugins/baser-core/tests/TestCase/Controller/Admin/PermissionGroupsControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/Admin/PermissionGroupsControllerTest.php @@ -107,6 +107,14 @@ public function test_edit() $this->loadFixtureScenario(PermissionGroupsScenario::class); $data = [ 'name' => 'システム基本設定 Update', + 'permissions' => [[ + 'id' => "1", + 'name' => "一覧", + 'user_group_id' => "2", + 'method' => "GET", + 'auth' => "1", + 'status' => "1" + ]] ]; $this->post('/baser/admin/baser-core/permission_groups/edit/1/1', $data); //メッセージを確認