Skip to content

Commit

Permalink
fix: subsite loading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Oct 24, 2023
1 parent 0890b85 commit 347cc65
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
6 changes: 2 additions & 4 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion src/Extensions/MenuSubsiteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions src/Extensions/SubsiteExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Heyday\MenuManager\Extensions;

use Heyday\MenuManager\MenuSet;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HiddenField;
use SilverStripe\ORM\DataExtension;

if (!class_exists('\SilverStripe\Subsites\Model\Subsite') || !class_exists('\SilverStripe\Subsites\State\SubsiteState')) {
return;
}

class SubsiteExtension extends DataExtension
{
private static $has_many = [
'MenuSets' => MenuSet::class
];

private static $cascade_deletes = [
'MenuSets'
];

public function updateCMSFields(FieldList $fields)
{
$fields->removeByName('MenuSets');
}
}

0 comments on commit 347cc65

Please sign in to comment.