‪TYPO3CMS  ‪main
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  $menuObjectFactory = GeneralUtility::makeInstance(MenuContentObjectFactory::class);
44  $menu = $menuObjectFactory->getMenuObjectByType($menuType);
45  if (isset($frontendController->register['count_HMENU'])) {
46  $frontendController->register['count_HMENU']++;
47  } else {
48  $frontendController->register['count_HMENU'] = 1;
49  }
50  $frontendController->register['count_HMENU_MENUOBJ'] = 0;
51  $frontendController->register['count_MENUOBJ'] = 0;
52  $menu->parent_cObj = $this->‪getContentObjectRenderer();
53  $menu->start(null, $this->‪getPageRepository(), '', $conf, 1, '', $this->request);
54  $menu->makeMenu();
55  $theValue .= $menu->writeMenu();
56  } catch (‪NoSuchMenuTypeException $e) {
57  }
58  $wrap = $this->cObj->stdWrapValue('wrap', $conf);
59  if ($wrap) {
60  $theValue = $this->cObj->wrap($theValue, $wrap);
61  }
62  if (isset($conf['stdWrap.'])) {
63  $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
64  }
65  return $theValue;
66  }
67 }
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getContentObjectRenderer
‪getContentObjectRenderer()
Definition: AbstractContentObject.php:51
‪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:18
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getPageRepository
‪getPageRepository()
Definition: AbstractContentObject.php:88
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
Definition: AbstractContentObject.php:31
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getTypoScriptFrontendController
‪getTypoScriptFrontendController()
Definition: AbstractContentObject.php:79
‪TYPO3\CMS\Frontend\ContentObject\HierarchicalMenuContentObject\render
‪string render($conf=[])
Definition: HierarchicalMenuContentObject.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory
Definition: MenuContentObjectFactory.php:31