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