Skip to content

Commit

Permalink
Merge pull request #1572 from creative-commoners/pulls/1.13/disable-h…
Browse files Browse the repository at this point in the history
…elp-links

ENH Allow disabling of help_links
  • Loading branch information
GuySartorelli authored Sep 4, 2023
2 parents 714c773 + 105b5ce commit ec30bf3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 11 additions & 6 deletions code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,8 @@ public function SiteConfig()
/**
* The urls used for the links in the Help dropdown in the backend
*
* Set this to `false` via yml config if you do not want to show any help links
*
* @config
* @var array
*/
Expand All @@ -1889,13 +1891,16 @@ public function getHelpLinks()
}
});

foreach ($helpLinks as $key => $value) {
$translationKey = str_replace(' ', '', $key ?? '');
// Setting the `help_links` config to `false` means no help links will show
if (is_array($helpLinks)) {
foreach ($helpLinks as $key => $value) {
$translationKey = str_replace(' ', '', $key ?? '');

$formattedLinks[] = [
'Title' => _t(__CLASS__ . '.' . $translationKey, $key),
'URL' => $value
];
$formattedLinks[] = [
'Title' => _t(__CLASS__ . '.' . $translationKey, $key),
'URL' => $value
];
}
}

return ArrayList::create($formattedLinks);
Expand Down
7 changes: 7 additions & 0 deletions tests/php/LeftAndMainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ec30bf3

Please sign in to comment.