Skip to content

Commit

Permalink
ENH Use config instead of runtime code to remove menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Oct 14, 2024
1 parent bd48b04 commit 2fa2aa3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
10 changes: 0 additions & 10 deletions _config.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?php

use SilverStripe\Admin\CMSMenu;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Controllers\CMSPageAddController;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\CMS\Controllers\CMSPageSettingsController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
Expand All @@ -31,8 +26,3 @@
'sitetree_link',
[SiteTree::class, 'link_shortcode_handler']
);

CMSMenu::remove_menu_class(CMSMain::class);
CMSMenu::remove_menu_class(CMSPageEditController::class);
CMSMenu::remove_menu_class(CMSPageSettingsController::class);
CMSMenu::remove_menu_class(CMSPageAddController::class);
2 changes: 2 additions & 0 deletions code/Controllers/CMSPageAddController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class CMSPageAddController extends CMSPageEditController
private static $menu_title = 'Add page';
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';

private static $ignore_menuitem = true;

private static $allowed_actions = [
'AddForm',
'doAdd',
Expand Down
2 changes: 2 additions & 0 deletions code/Controllers/CMSPageEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CMSPageEditController extends CMSMain

private static $required_permission_codes = 'CMS_ACCESS_CMSMain';

private static $ignore_menuitem = true;

private static $allowed_actions = [
'AddToCampaignForm',
];
Expand Down
2 changes: 2 additions & 0 deletions code/Controllers/CMSPageSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class CMSPageSettingsController extends CMSMain

private static $required_permission_codes = 'CMS_ACCESS_CMSMain';

private static $ignore_menuitem = true;

public function getEditForm($id = null, $fields = null)
{
$record = $this->getRecord($id ?: $this->currentPageID());
Expand Down

0 comments on commit 2fa2aa3

Please sign in to comment.