‪TYPO3CMS  10.4
ClassNamingUtility.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 
24 {
33  public static function ‪translateModelNameToRepositoryName($modelName)
34  {
35  return str_replace(
36  '\\Domain\\Model',
37  '\\Domain\\Repository',
38  $modelName
39  ) . 'Repository';
40  }
41 
50  public static function ‪translateRepositoryNameToModelName($repositoryName)
51  {
52  return preg_replace(
53  ['/\\\\Domain\\\\Repository/', '/Repository$/'],
54  ['\\Domain\\Model', ''],
55  $repositoryName
56  );
57  }
58 
66  public static function ‪explodeObjectControllerName($controllerObjectName)
67  {
68  $matches = [];
69 
70  if (strpos($controllerObjectName, 'TYPO3\\CMS') === 0) {
71  $extensionName = '^(?P<vendorName>[^\\\\]+\\\[^\\\\]+)\\\‍(?P<extensionName>[^\\\\]+)';
72  } else {
73  $extensionName = '^(?P<vendorName>[^\\\\]+)\\\\(?P<extensionName>[^\\\\]+)';
74  }
75 
76  preg_match(
77  '/' . $extensionName . '\\\\(Controller|Command|(?P<subpackageKey>.+)\\\\Controller)\\\\(?P<controllerName>[a-z\\\\]+)Controller$/ix',
78  $controllerObjectName,
79  $matches
80  );
81 
82  return array_filter($matches, 'is_string', ARRAY_FILTER_USE_KEY);
83  }
84 }
‪TYPO3\CMS\Core\Utility
Definition: ArrayUtility.php:16
‪TYPO3\CMS\Core\Utility\ClassNamingUtility\translateModelNameToRepositoryName
‪static string translateModelNameToRepositoryName($modelName)
Definition: ClassNamingUtility.php:33
‪TYPO3\CMS\Core\Utility\ClassNamingUtility\explodeObjectControllerName
‪static array explodeObjectControllerName($controllerObjectName)
Definition: ClassNamingUtility.php:66
‪TYPO3\CMS\Core\Utility\ClassNamingUtility
Definition: ClassNamingUtility.php:24
‪TYPO3\CMS\Core\Utility\ClassNamingUtility\translateRepositoryNameToModelName
‪static string translateRepositoryNameToModelName($repositoryName)
Definition: ClassNamingUtility.php:50