From 347cc65446db98934d414ed35eff5669fca6529a Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 24 Oct 2023 14:47:25 +1300 Subject: [PATCH] fix: subsite loading issue --- _config/extensions.yml | 6 ++---- src/Extensions/MenuSubsiteExtension.php | 1 - src/Extensions/SubsiteExtension.php | 28 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/Extensions/SubsiteExtension.php diff --git a/_config/extensions.yml b/_config/extensions.yml index fdc21e0..4d60372 100644 --- a/_config/extensions.yml +++ b/_config/extensions.yml @@ -4,10 +4,8 @@ Only: classexists: '\SilverStripe\Subsites\Model\Subsite' --- SilverStripe\Subsites\Model\Subsite: - has_many: - - MenuSets => 'Heyday\MenuManager\MenuSet' - cascade_deletes: - - MenuSets + extensions: + - Heyday\MenuManager\Extensions\SubsiteExtension Heyday\MenuManager\MenuAdmin: extensions: - SilverStripe\Subsites\Extensions\SubsiteMenuExtension diff --git a/src/Extensions/MenuSubsiteExtension.php b/src/Extensions/MenuSubsiteExtension.php index 4fdbe34..3a23288 100644 --- a/src/Extensions/MenuSubsiteExtension.php +++ b/src/Extensions/MenuSubsiteExtension.php @@ -6,7 +6,6 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\HiddenField; use SilverStripe\ORM\DataExtension; -use SilverStripe\Subsites\State\SubsiteState; if (!class_exists('\SilverStripe\Subsites\Model\Subsite') || !class_exists('\SilverStripe\Subsites\State\SubsiteState')) { return; diff --git a/src/Extensions/SubsiteExtension.php b/src/Extensions/SubsiteExtension.php new file mode 100644 index 0000000..cf6bf66 --- /dev/null +++ b/src/Extensions/SubsiteExtension.php @@ -0,0 +1,28 @@ + MenuSet::class + ]; + + private static $cascade_deletes = [ + 'MenuSets' + ]; + + public function updateCMSFields(FieldList $fields) + { + $fields->removeByName('MenuSets'); + } +}