Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Allow disabling of help_links #1572

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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