‪TYPO3CMS  ‪main
ExtbaseModule.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 
30 {
31  protected string ‪$extensionName;
32  protected array ‪$controllerActions;
33 
37  protected string ‪$parent = 'web';
38 
42  protected string ‪$access = 'admin';
43 
44  public function ‪getExtensionName(): string
45  {
47  }
48 
49  public function ‪getControllerActions(): array
50  {
52  }
53 
54  public function ‪getDefaultRouteOptions(): array
55  {
56  $allRoutes = [];
57  foreach ($this->controllerActions as $controllerConfiguration) {
58  foreach ($controllerConfiguration['actions'] as $actionName) {
59  if ($allRoutes === []) {
60  $allRoutes['_default'] = array_replace_recursive(
61  $this->routeOptions,
62  [
63  'module' => $this,
64  'packageName' => $this->packageName,
65  'absolutePackagePath' => $this->absolutePackagePath,
66  'access' => $this->access,
67  'target' => Bootstrap::class . '::handleBackendRequest',
68  'controller' => $controllerConfiguration['alias'],
69  'action' => $actionName,
70  ]
71  );
72  }
73  $allRoutes[$controllerConfiguration['alias'] . '_' . $actionName] = array_replace_recursive(
74  $this->routeOptions,
75  [
76  'module' => $this,
77  'path' => $controllerConfiguration['alias'] . '/' . $actionName,
78  'packageName' => $this->packageName,
79  'absolutePackagePath' => $this->absolutePackagePath,
80  'access' => $this->access,
81  'target' => Bootstrap::class . '::handleBackendRequest',
82  'controller' => $controllerConfiguration['alias'],
83  'action' => $actionName,
84  ]
85  );
86  }
87  }
88  return $allRoutes;
89  }
90 
91  protected static function ‪sanitizeExtensionName(string ‪$extensionName): string
92  {
93  return (string)str_replace(' ', '', ucwords(str_replace('_', ' ', ‪$extensionName)));
94  }
95 
96  protected static function ‪sanitizeControllerActions(array ‪$controllerActions): array
97  {
98  $sanitizedControllerActions = [];
99  foreach (‪$controllerActions as $controllerName => $actions) {
100  $sanitizedControllerActions[$controllerName] = [
101  'actions' => (is_array($actions) ? $actions : ‪GeneralUtility::trimExplode(',', $actions)),
103  'className' => $controllerName,
104  ];
105  }
106  return $sanitizedControllerActions;
107  }
108 
109  public static function ‪createFromConfiguration(string ‪$identifier, array $configuration): static
110  {
111  $obj = parent::createFromConfiguration(‪$identifier, $configuration);
112  $obj->extensionName = ‪self::sanitizeExtensionName((string)($configuration['extensionName'] ?? ''));
113  $obj->controllerActions = ‪self::sanitizeControllerActions((array)($configuration['controllerActions'] ?? []));
114  return $obj;
115  }
116 }
‪TYPO3\CMS\Backend\Module\ExtbaseModule\sanitizeExtensionName
‪static sanitizeExtensionName(string $extensionName)
Definition: ExtbaseModule.php:91
‪TYPO3\CMS\Extbase\Utility\ExtensionUtility
Definition: ExtensionUtility.php:27
‪TYPO3\CMS\Backend\Module\ExtbaseModule\getExtensionName
‪getExtensionName()
Definition: ExtbaseModule.php:44
‪TYPO3\CMS\Backend\Module\ExtbaseModule\$extensionName
‪string $extensionName
Definition: ExtbaseModule.php:31
‪TYPO3\CMS\Backend\Module\BaseModule
Definition: BaseModule.php:26
‪TYPO3\CMS\Backend\Module\ExtbaseModule\sanitizeControllerActions
‪static sanitizeControllerActions(array $controllerActions)
Definition: ExtbaseModule.php:96
‪TYPO3\CMS\Backend\Module\ExtbaseModule\$controllerActions
‪array $controllerActions
Definition: ExtbaseModule.php:32
‪TYPO3\CMS\Backend\Module\ExtbaseModule\$parent
‪string $parent
Definition: ExtbaseModule.php:37
‪TYPO3\CMS\Backend\Module\ExtbaseModule
Definition: ExtbaseModule.php:30
‪TYPO3\CMS\Backend\Module\BaseModule\$identifier
‪string $identifier
Definition: BaseModule.php:27
‪TYPO3\CMS\Backend\Module\ExtbaseModule\getDefaultRouteOptions
‪getDefaultRouteOptions()
Definition: ExtbaseModule.php:54
‪TYPO3\CMS\Backend\Module\ModuleInterface
Definition: ModuleInterface.php:24
‪TYPO3\CMS\Backend\Module\ExtbaseModule\getControllerActions
‪getControllerActions()
Definition: ExtbaseModule.php:49
‪TYPO3\CMS\Backend\Module\ExtbaseModule\$access
‪string $access
Definition: ExtbaseModule.php:42
‪TYPO3\CMS\Backend\Module\ExtbaseModule\createFromConfiguration
‪static createFromConfiguration(string $identifier, array $configuration)
Definition: ExtbaseModule.php:109
‪TYPO3\CMS\Extbase\Core\Bootstrap
Definition: Bootstrap.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Module
Definition: BaseModule.php:18
‪TYPO3\CMS\Extbase\Utility\ExtensionUtility\resolveControllerAliasFromControllerClassName
‪static resolveControllerAliasFromControllerClassName(string $controllerClassName)
Definition: ExtensionUtility.php:164
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822