‪TYPO3CMS  11.5
HierarchicalMenuContentObject.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
26 {
33  public function ‪render($conf = [])
34  {
35  if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
36  return '';
37  }
38 
39  $theValue = '';
40  $menuType = $conf[1] ?? '';
41  try {
42  $frontendController = $this->‪getTypoScriptFrontendController();
43 
45  $menuObjectFactory = GeneralUtility::makeInstance(MenuContentObjectFactory::class);
46  $menu = $menuObjectFactory->getMenuObjectByType($menuType);
47  if (isset($frontendController->register['count_HMENU'])) {
48  $frontendController->register['count_HMENU']++;
49  } else {
50  $frontendController->register['count_HMENU'] = 1;
51  }
52  $frontendController->register['count_HMENU_MENUOBJ'] = 0;
53  $frontendController->register['count_MENUOBJ'] = 0;
54  $menu->parent_cObj = ‪$this->cObj;
55  $menu->start($frontendController->tmpl, $this->getPageRepository(), '', $conf, 1, '', $this->request);
56  $menu->makeMenu();
57  $theValue .= $menu->writeMenu();
58  } catch (‪NoSuchMenuTypeException $e) {
59  }
60  $wrap = $this->cObj->stdWrapValue('wrap', $conf ?? []);
61  if ($wrap) {
62  $theValue = $this->cObj->wrap($theValue, $wrap);
63  }
64  if (isset($conf['stdWrap.'])) {
65  $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
66  }
67  return $theValue;
68  }
69 }
‪TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException
Definition: NoSuchMenuTypeException.php:23
‪TYPO3\CMS\Frontend\ContentObject\HierarchicalMenuContentObject
Definition: HierarchicalMenuContentObject.php:26
‪TYPO3\CMS\Frontend\ContentObject
Definition: AbstractContentObject.php:16
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: AbstractContentObject.php:86
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
Definition: AbstractContentObject.php:29
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\$cObj
‪ContentObjectRenderer $cObj
Definition: AbstractContentObject.php:32
‪TYPO3\CMS\Frontend\ContentObject\HierarchicalMenuContentObject\render
‪string render($conf=[])
Definition: HierarchicalMenuContentObject.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory
Definition: MenuContentObjectFactory.php:29