‪TYPO3CMS  ‪main
MenuContentObjectFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
31 {
35  protected array ‪$menuTypeToClassMapping = [
36  'TMENU' => TextMenuContentObject::class,
37  ];
38 
44  public function ‪getMenuObjectByType(string $type = ''): ‪AbstractMenuContentObject
45  {
46  $upperCasedClassName = strtoupper($type);
47  if (array_key_exists($upperCasedClassName, $this->menuTypeToClassMapping)) {
49  $object = GeneralUtility::makeInstance($this->menuTypeToClassMapping[$upperCasedClassName]);
50  return $object;
51  }
53  'Menu type ' . (string)$type . ' has no implementing class.',
54  1363278130
55  );
56  }
57 
64  public function ‪registerMenuType(string $type, string $className)
65  {
66  $this->menuTypeToClassMapping[strtoupper($type)] = $className;
67  }
68 }
‪TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException
Definition: NoSuchMenuTypeException.php:23
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
Definition: AbstractMenuContentObject.php:53
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory\registerMenuType
‪registerMenuType(string $type, string $className)
Definition: MenuContentObjectFactory.php:64
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory\$menuTypeToClassMapping
‪array $menuTypeToClassMapping
Definition: MenuContentObjectFactory.php:35
‪TYPO3\CMS\Frontend\ContentObject\Menu
Definition: AbstractMenuContentObject.php:16
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory\getMenuObjectByType
‪getMenuObjectByType(string $type='')
Definition: MenuContentObjectFactory.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory
Definition: MenuContentObjectFactory.php:31