-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply getCurrentMenuSetParent to Controller automatically, with updat…
…e hook
- Loading branch information
1 parent
c5b6329
commit c0e3fc1
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
--- | ||
Name: fromholdio-superlinker-menus | ||
--- | ||
|
||
SilverStripe\Control\Controller: | ||
extensions: | ||
menuSetParent: Fromholdio\SuperLinkerMenus\Extensions\MenuSetParentAccessorExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Fromholdio\SuperLinkerMenus\Extensions; | ||
|
||
use SilverStripe\Core\Extension; | ||
use SilverStripe\Core\Manifest\ModuleLoader; | ||
use SilverStripe\SiteConfig\SiteConfig; | ||
use Symbiote\Multisites\Multisites; | ||
|
||
class MenuSetParentAccessorExtension extends Extension | ||
{ | ||
public function getCurrentMenuSetParent() | ||
{ | ||
$isMultisites = ModuleLoader::inst() | ||
->getManifest() | ||
->moduleExists('symbiote/silverstripe-multisites'); | ||
$parent = $isMultisites | ||
? Multisites::inst()->getCurrentSite() | ||
: SiteConfig::current_site_config(); | ||
$this->getOwner()->invokeWithExtensions('updateCurrentMenuSetParent', $parent); | ||
return $parent; | ||
} | ||
} |