TYPO3 CMS  TYPO3_6-2
ClassNamingUtility.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Utility;
3 
24 
33  static public function translateModelNameToRepositoryName($modelName) {
34  return str_replace(
35  array('\\Domain\\Model', '_Domain_Model_'),
36  array('\\Domain\\Repository', '_Domain_Repository_'),
37  $modelName
38  ) . 'Repository';
39  }
40 
49  static public function translateModelNameToValidatorName($modelName) {
50  return str_replace(
51  array('\\Domain\\Model\\', '_Domain_Model_'),
52  array('\\Domain\\Validator\\', '_Domain_Validator_'),
53  $modelName
54  ) . 'Validator';
55  }
56 
65  static public function translateRepositoryNameToModelName($repositoryName) {
66  return preg_replace(
67  array('/\\\\Domain\\\\Repository/', '/_Domain_Repository_/', '/Repository$/'),
68  array('\\Domain\\Model', '_Domain_Model_', ''),
69  $repositoryName
70  );
71  }
72 
73 
74 
82  static public function explodeObjectControllerName($controllerObjectName) {
83  $matches = array();
84 
85  if (strpos($controllerObjectName, '\\') !== FALSE) {
86  if (substr($controllerObjectName, 0, 9) === 'TYPO3\\CMS') {
87  $extensionName = '^(?P<vendorName>[^\\\\]+\\\[^\\\\]+)\\\(?P<extensionName>[^\\\\]+)';
88  } else {
89  $extensionName = '^(?P<vendorName>[^\\\\]+)\\\\(?P<extensionName>[^\\\\]+)';
90  }
91 
92  preg_match(
93  '/' . $extensionName . '\\\\(Controller|Command|(?P<subpackageKey>.+)\\\\Controller)\\\\(?P<controllerName>[a-z\\\\]+)Controller$/ix',
94  $controllerObjectName,
95  $matches
96  );
97  } else {
98  preg_match(
99  '/^Tx_(?P<extensionName>[^_]+)_(Controller|Command|(?P<subpackageKey>.+)_Controller)_(?P<controllerName>[a-z_]+)Controller$/ix',
100  $controllerObjectName,
101  $matches
102  );
103  }
104 
105  return $matches;
106  }
107 }
static explodeObjectControllerName($controllerObjectName)
static translateRepositoryNameToModelName($repositoryName)