From 325d87ca9fb188b66e1490e5ee09634d577343b8 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 4 Sep 2023 16:30:12 +1200 Subject: [PATCH] ENH Allow disabling of help_links --- code/LeftAndMain.php | 16 +++++++++------- tests/php/LeftAndMainTest.php | 7 +++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index b180e23f5..9ad1f6215 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -1889,13 +1889,15 @@ public function getHelpLinks() } }); - foreach ($helpLinks as $key => $value) { - $translationKey = str_replace(' ', '', $key ?? ''); - - $formattedLinks[] = [ - 'Title' => _t(__CLASS__ . '.' . $translationKey, $key), - 'URL' => $value - ]; + if ($helpLinks) { + foreach ($helpLinks as $key => $value) { + $translationKey = str_replace(' ', '', $key ?? ''); + + $formattedLinks[] = [ + 'Title' => _t(__CLASS__ . '.' . $translationKey, $key), + 'URL' => $value + ]; + } } return ArrayList::create($formattedLinks); diff --git a/tests/php/LeftAndMainTest.php b/tests/php/LeftAndMainTest.php index 6f60b9dd0..91d4166f1 100644 --- a/tests/php/LeftAndMainTest.php +++ b/tests/php/LeftAndMainTest.php @@ -215,6 +215,13 @@ public function testGetHelpLinks() $this->assertEquals('www.silverstripe.org', $silverstripeLink['URL']); } + public function testDisableHelpLinks() + { + Config::modify()->set(LeftAndMain::class, 'help_links', false); + $helpLinks = LeftAndMain::singleton()->getHelpLinks(); + $this->assertCount(0, $helpLinks); + } + /** * @dataProvider provideTestCMSVersionNumber */