vendor/dklemmt/contao_dk_mmenu/src/FrontendModule/MmenuModule.php line 61

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the ContaoMmenuBundle.
  5.  *
  6.  * (c) Dirk Klemmt
  7.  * (c) inspiredminds
  8.  *
  9.  * @license MIT
  10.  */
  11. namespace DirkKlemmt\ContaoMmenuBundle\FrontendModule;
  12. use Contao\BackendTemplate;
  13. use Contao\ModuleNavigation;
  14. use DirkKlemmt\ContaoMmenuBundle\Helper\MmenuHelper;
  15. class MmenuModule extends ModuleNavigation
  16. {
  17.     /**
  18.      * Template.
  19.      *
  20.      * @var string
  21.      */
  22.     protected $strTemplate 'mod_mmenu';
  23.     /**
  24.      * Template.
  25.      */
  26.     protected string $strTemplateJs 'mmenu_default';
  27.     /**
  28.      * Display a wildcard in the back end.
  29.      */
  30.     public function generate(): string
  31.     {
  32.         if (TL_MODE === 'BE') {
  33.             // --- create BE template for mmenu module
  34.             $template = new BackendTemplate('be_wildcard');
  35.             $template->wildcard '### '.mb_strtoupper($GLOBALS['TL_LANG']['FMD']['mmenu'][0]).' ###';
  36.             $template->title $this->headline;
  37.             $template->id $this->id;
  38.             $template->link $this->name;
  39.             $template->href 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id='.$this->id;
  40.             return $template->parse();
  41.         }
  42.         // replace default (HTML) template with chosen one
  43.         if ($this->customTpl) {
  44.             $this->strTemplate $this->customTpl;
  45.         }
  46.         // replace default (JS) template with chosen one
  47.         if ($this->dk_mmenuJsTpl) {
  48.             $this->strTemplateJs $this->dk_mmenuJsTpl;
  49.         }
  50.         return parent::generate();
  51.     }
  52.     /**
  53.      * Generate the module.
  54.      */
  55.     protected function compile(): void
  56.     {
  57.         // Navigation template fallback
  58.         if ('' === $this->navigationTpl) {
  59.             $this->navigationTpl 'nav_mmenu';
  60.         }
  61.         // Build the navigation items
  62.         parent::compile();
  63.         // Add the JavaScript to TL_BODY
  64.         MmenuHelper::processModuleSettings($this$this->strTemplateJs);
  65.     }
  66. }