[TASK] Rename deprecation message version from 1.6 to 6.0
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Utility / Extension.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Utilities to manage plugins and modules of an extension. Also useful to auto-generate the autoloader registry
27 * file ext_autoload.php.
28 *
29 * @package Extbase
30 * @subpackage Utility
31 */
32 class Tx_Extbase_Utility_Extension {
33
34 const PLUGIN_TYPE_PLUGIN = 'list_type';
35 const PLUGIN_TYPE_CONTENT_ELEMENT = 'CType';
36
37 /**
38 * @var Tx_Extbase_Service_ExtensionService
39 */
40 protected static $extensionService = NULL;
41
42 /**
43 * @return void
44 */
45 static protected function getExtensionService() {
46 if (self::$extensionService === NULL) {
47 require_once t3lib_extMgm::extPath('extbase', 'Classes/Service/ExtensionService.php');
48 $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
49 self::$extensionService = $objectManager->get('Tx_Extbase_Service_ExtensionService');
50 }
51 return self::$extensionService;
52 }
53
54 /**
55 * Add auto-generated TypoScript to configure the Extbase Dispatcher.
56 *
57 * When adding a frontend plugin you will have to add both an entry to the TCA definition
58 * of tt_content table AND to the TypoScript template which must initiate the rendering.
59 * Since the static template with uid 43 is the "content.default" and practically always
60 * used for rendering the content elements it's very useful to have this function automatically
61 * adding the necessary TypoScript for calling the appropriate controller and action of your plugin.
62 * It will also work for the extension "css_styled_content"
63 * FOR USE IN ext_localconf.php FILES
64 * Usage: 2
65 *
66 * @param string $extensionName The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
67 * @param string $pluginName must be a unique id for your plugin in UpperCamelCase (the string length of the extension key added to the length of the plugin name should be less than 32!)
68 * @param string $controllerActions is an array of allowed combinations of controller and action stored in an array (controller name as key and a comma separated list of action names as value, the first controller and its first action is chosen as default)
69 * @param string $nonCacheableControllerActions is an optional array of controller name and action names which should not be cached (array as defined in $controllerActions)
70 * @param string $defaultControllerAction is an optional array controller name (as array key) and action name (as array value) that should be called as default
71 * @param string $pluginType either Tx_Extbase_Utility_Extension::TYPE_PLUGIN (default) or Tx_Extbase_Utility_Extension::TYPE_CONTENT_ELEMENT
72 * @return void
73 */
74 static public function configurePlugin($extensionName, $pluginName, array $controllerActions, array $nonCacheableControllerActions = array(), $pluginType = self::PLUGIN_TYPE_PLUGIN) {
75 if (empty($pluginName)) {
76 throw new InvalidArgumentException('The plugin name must not be empty', 1239891987);
77 }
78 if (empty($extensionName)) {
79 throw new InvalidArgumentException('The extension name was invalid (must not be empty and must match /[A-Za-z][_A-Za-z0-9]/)', 1239891989);
80 }
81 $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName)));
82 $pluginSignature = strtolower($extensionName) . '_' . strtolower($pluginName);
83 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName])) {
84 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName] = array();
85 }
86
87 foreach ($controllerActions as $controllerName => $actionsList) {
88 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'][$controllerName] = array('actions' => t3lib_div::trimExplode(',', $actionsList));
89 if (!empty($nonCacheableControllerActions[$controllerName])) {
90 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'][$controllerName]['nonCacheableActions'] = t3lib_div::trimExplode(',', $nonCacheableControllerActions[$controllerName]);
91 }
92 }
93
94 $pluginTemplate = 'plugin.tx_' . strtolower($extensionName) . ' {
95 settings {
96 }
97 persistence {
98 storagePid =
99 classes {
100 }
101 }
102 view {
103 templateRootPath =
104 layoutRootPath =
105 partialRootPath =
106 # with defaultPid you can specify the default page uid of this plugin. If you set this to the string "auto" the target page will be determined automatically. Defaults to an empty string that expects the target page to be the current page.
107 defaultPid =
108 }
109 }';
110 t3lib_extMgm::addTypoScript($extensionName, 'setup', '
111 # Setting ' . $extensionName . ' plugin TypoScript
112 ' . $pluginTemplate);
113
114 switch ($pluginType) {
115 case self::PLUGIN_TYPE_PLUGIN:
116 $pluginContent = trim('
117 tt_content.list.20.' . $pluginSignature . ' = USER
118 tt_content.list.20.' . $pluginSignature . ' {
119 userFunc = tx_extbase_core_bootstrap->run
120 extensionName = ' . $extensionName . '
121 pluginName = ' . $pluginName . '
122 }');
123 break;
124 case self::PLUGIN_TYPE_CONTENT_ELEMENT:
125 $pluginContent = trim('
126 tt_content.' . $pluginSignature . ' = COA
127 tt_content.' . $pluginSignature . ' {
128 10 = < lib.stdheader
129 20 = USER
130 20 {
131 userFunc = tx_extbase_core_bootstrap->run
132 extensionName = ' . $extensionName . '
133 pluginName = ' . $pluginName . '
134 }
135 }');
136 break;
137 default:
138 throw new InvalidArgumentException('The pluginType "' . $pluginType .'" is not suported', 1289858856);
139 }
140 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['pluginType'] = $pluginType;
141
142 t3lib_extMgm::addTypoScript($extensionName, 'setup', '
143 # Setting ' . $extensionName . ' plugin TypoScript
144 ' . $pluginContent, 43);
145 }
146
147 /**
148 * Register an Extbase PlugIn into backend's list of plugins
149 * FOR USE IN ext_tables.php FILES
150 *
151 * @param string $extensionName The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
152 * @param string $pluginName must be a unique id for your plugin in UpperCamelCase (the string length of the extension key added to the length of the plugin name should be less than 32!)
153 * @param string $pluginTitle is a speaking title of the plugin that will be displayed in the drop down menu in the backend
154 * @param string $pluginIconPathAndFilename is a path to an icon file (relative to TYPO3_mainDir), that will be displayed in the drop down menu in the backend (optional)
155 * @return void
156 */
157 static public function registerPlugin($extensionName, $pluginName, $pluginTitle, $pluginIconPathAndFilename = NULL) {
158 if (empty($pluginName)) {
159 throw new InvalidArgumentException('The plugin name must not be empty', 1239891987);
160 }
161 if (empty($extensionName)) {
162 throw new InvalidArgumentException('The extension name was invalid (must not be empty and must match /[A-Za-z][_A-Za-z0-9]/)', 1239891989);
163 }
164 $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName)));
165 $pluginSignature = strtolower($extensionName) . '_' . strtolower($pluginName);
166
167 t3lib_extMgm::addPlugin(array($pluginTitle, $pluginSignature, $pluginIconPathAndFilename), $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['pluginType']);
168 }
169
170 /**
171 * This method is called from t3lib_loadModules::checkMod and it replaces old conf.php.
172 *
173 * @param string $moduleSignature The module name
174 * @param string $modulePath Absolute path to module (not used by Extbase currently)
175 * @return array Configuration of the module
176 */
177 public function configureModule($moduleSignature, $modulePath) {
178 $moduleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature];
179 $iconPathAndFilename = $moduleConfiguration['icon'];
180 if (substr($iconPathAndFilename, 0, 4) === 'EXT:') {
181 list($extensionKey, $relativePath) = explode('/', substr($iconPathAndFilename, 4), 2);
182 $iconPathAndFilename = t3lib_extMgm::extPath($extensionKey) . $relativePath;
183 }
184 // TODO: skin support
185
186 $moduleLabels = array(
187 'tabs_images' => array(
188 'tab' => $iconPathAndFilename,
189 ),
190 'labels' => array(
191 'tablabel' => $GLOBALS['LANG']->sL($moduleConfiguration['labels'] . ':mlang_labels_tablabel'),
192 'tabdescr' => $GLOBALS['LANG']->sL($moduleConfiguration['labels'] . ':mlang_labels_tabdescr'),
193 ),
194 'tabs' => array(
195 'tab' => $GLOBALS['LANG']->sL($moduleConfiguration['labels'] . ':mlang_tabs_tab')
196 )
197 );
198 $GLOBALS['LANG']->addModuleLabels($moduleLabels, $moduleSignature . '_');
199
200 return $moduleConfiguration;
201 }
202
203 /**
204 * Registers an Extbase module (main or sub) to the backend interface.
205 * FOR USE IN ext_tables.php FILES
206 *
207 * @param string $extensionName The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
208 * @param string $mainModuleName The main module key, $sub is the submodule key. So $main would be an index in the $TBE_MODULES array and $sub could be an element in the lists there. If $main is not set a blank $extensionName module is created
209 * @param string $subModuleName The submodule key. If $sub is not set a blank $main module is created
210 * @param string $position This can be used to set the position of the $sub module within the list of existing submodules for the main module. $position has this syntax: [cmd]:[submodule-key]. cmd can be "after", "before" or "top" (or blank which is default). If "after"/"before" then submodule will be inserted after/before the existing submodule with [submodule-key] if found. If not found, the bottom of list. If "top" the module is inserted in the top of the submodule list.
211 * @param array $controllerActions is an array of allowed combinations of controller and action stored in an array (controller name as key and a comma separated list of action names as value, the first controller and its first action is chosen as default)
212 * @param array $moduleConfiguration The configuration options of the module (icon, locallang.xml file)
213 * @return void
214 */
215 static public function registerModule($extensionName, $mainModuleName = '', $subModuleName = '', $position = '', array $controllerActions, array $moduleConfiguration = array()) {
216 if (empty($extensionName)) {
217 throw new InvalidArgumentException('The extension name must not be empty', 1239891989);
218 }
219 $extensionKey = t3lib_div::camelCaseToLowerCaseUnderscored($extensionName);
220 $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName)));
221
222 $defaultModuleConfiguration = array(
223 'access' => 'admin',
224 'icon' => 'EXT:extbase/ext_icon.gif',
225 'labels' => '',
226 'extRelPath' => t3lib_extMgm::extRelPath($extensionKey) . 'Classes/'
227 );
228
229 if ((strlen($mainModuleName) > 0) && !array_key_exists($mainModuleName, $GLOBALS['TBE_MODULES'])) {
230 $mainModuleName = $extensionName . t3lib_div::underscoredToUpperCamelCase($mainModuleName);
231 } else {
232 $mainModuleName = (strlen($mainModuleName) > 0) ? $mainModuleName : 'web';
233 }
234
235 // add mandatory parameter to use new pagetree
236 if ($mainModuleName === 'web') {
237 $defaultModuleConfiguration['navigationComponentId'] = 'typo3-pagetree';
238 }
239
240 $moduleConfiguration = t3lib_div::array_merge_recursive_overrule($defaultModuleConfiguration, $moduleConfiguration);
241
242 $moduleSignature = $mainModuleName;
243
244 if ((strlen($subModuleName) > 0)) {
245 $subModuleName = $extensionName . t3lib_div::underscoredToUpperCamelCase($subModuleName);
246 $moduleSignature .= '_' . $subModuleName;
247 }
248
249 $moduleConfiguration['name'] = $moduleSignature;
250 $moduleConfiguration['script'] = 'mod.php?M=' . rawurlencode($moduleSignature);
251 $moduleConfiguration['extensionName'] = $extensionName;
252 $moduleConfiguration['configureModuleFunction'] = array('Tx_Extbase_Utility_Extension', 'configureModule');
253
254 $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] = $moduleConfiguration;
255
256 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$moduleSignature])) {
257 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$moduleSignature] = array();
258 }
259 foreach($controllerActions as $controllerName => $actions) {
260 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$moduleSignature]['controllers'][$controllerName] = array(
261 'actions' => t3lib_div::trimExplode(',' , $actions)
262 );
263 }
264
265 t3lib_extMgm::addModule($mainModuleName, $subModuleName, $position);
266 }
267
268 /**
269 * Register a type converter by class name.
270 *
271 * @param string $typeConverterClassName
272 * @return void
273 * @api
274 */
275 static public function registerTypeConverter($typeConverterClassName) {
276 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'])) {
277 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = array();
278 }
279 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = $typeConverterClassName;
280 }
281
282 /**
283 * Returns a given CamelCasedString as an lowercase string with underscores.
284 * Example: Converts BlogExample to blog_example, and minimalValue to minimal_value
285 *
286 * @param string $string
287 * @return mixed
288 * @see t3lib_div::underscoredToLowerCamelCase()
289 * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0
290 */
291 static public function convertCamelCaseToLowerCaseUnderscored($string) {
292 t3lib_div::logDeprecatedFunction();
293 return t3lib_div::camelCaseToLowerCaseUnderscored($string);
294 }
295
296 /**
297 * Returns a given string with underscores as lowerCamelCase.
298 * Example: Converts minimal_value to minimalValue
299 *
300 * @param string $string
301 * @return mixed
302 * @see t3lib_div::underscoredToLowerCamelCase()
303 * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0
304 */
305 static public function convertUnderscoredToLowerCamelCase($string) {
306 t3lib_div::logDeprecatedFunction();
307 return t3lib_div::underscoredToLowerCamelCase($string);
308 }
309
310 /**
311 * Returns a given string with underscores as UpperCamelCase.
312 * Example: Converts blog_example to BlogExample
313 *
314 * @param string $string
315 * @return string
316 * @see t3lib_div::underscoredToUpperCamelCase()
317 * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0
318 */
319 static public function convertLowerUnderscoreToUpperCamelCase($string) {
320 t3lib_div::logDeprecatedFunction();
321 return t3lib_div::underscoredToUpperCamelCase($string);
322 }
323
324 /**
325 * Build the autoload registry for a given extension and place it ext_autoload.php.
326 *
327 * @param string $extensionKey Key of the extension
328 * @param string $extensionPath full path of the extension
329 * @param array $additionalAutoloadClasses additional classes to be added to the autoloader. The key must be the classname all-lowercase, the value must be the entry to be inserted
330 * @return string HTML string which should be outputted
331 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0
332 */
333 static public function createAutoloadRegistryForExtension($extensionKey, $extensionPath, $additionalAutoloadClasses = array()) {
334 t3lib_div::logDeprecatedFunction();
335 $classNameToFileMapping = array();
336 $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionKey)));
337 $errors = self::buildAutoloadRegistryForSinglePath($classNameToFileMapping, $extensionPath . 'Classes/', '.*tslib.*', '$extensionClassesPath . \'|\'');
338 if ($errors) {
339 return $errors;
340 }
341 $globalPrefix = '$extensionClassesPath = t3lib_extMgm::extPath(\'' . $extensionKey . '\') . \'Classes/\';';
342
343 $errors = array();
344 foreach ($classNameToFileMapping as $className => $fileName) {
345 if (!(strpos($className, 'tx_' . strtolower($extensionName)) === 0)) {
346 $errors[] = $className . ' does not start with Tx_' . $extensionName . ' and was not added to the autoloader registry.';
347 unset($classNameToFileMapping[$className]);
348 }
349 }
350 $classNameToFileMapping = array_merge($classNameToFileMapping, $additionalAutoloadClasses);
351 $autoloadFileString = self::generateAutoloadPhpFileData($classNameToFileMapping, $globalPrefix);
352 if (!@file_put_contents($extensionPath . 'ext_autoload.php', $autoloadFileString)) {
353 $errors[] = '<b>' . $extensionPath . 'ext_autoload.php could not be written!</b>';
354 }
355 $errors[] = 'Wrote the following data: <pre>' . htmlspecialchars($autoloadFileString) . '</pre>';
356 return implode('<br />', $errors);
357 }
358
359 /**
360 * Generate autoload PHP file data. Takes an associative array with class name to file mapping, and outputs it as PHP.
361 * Does NOT escape the values in the associative array. Includes the <?php ... ?> syntax and an optional global prefix.
362 *
363 * @param array $classNameToFileMapping class name to file mapping
364 * @param string $globalPrefix Global prefix which is prepended to all code.
365 * @return string The full PHP string
366 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0
367 */
368 protected function generateAutoloadPhpFileData($classNameToFileMapping, $globalPrefix = '') {
369 $output = '<?php' . PHP_EOL;
370 $output .= '// DO NOT CHANGE THIS FILE! It is automatically generated by Tx_Extbase_Utility_Extension::createAutoloadRegistryForExtension.' . PHP_EOL;
371 $output .= '// This file was generated on ' . date('Y-m-d H:i') . PHP_EOL;
372 $output .= PHP_EOL;
373 $output .= $globalPrefix . PHP_EOL;
374 $output .= 'return array(' . PHP_EOL;
375 foreach ($classNameToFileMapping as $className => $quotedFileName) {
376 $output .= ' \'' . $className . '\' => ' . $quotedFileName . ',' . PHP_EOL;
377 }
378 $output .= ');' . PHP_EOL;
379 $output .= '?>';
380 return $output;
381 }
382
383 /**
384 * Generate the $classNameToFileMapping for a given filePath.
385 *
386 * @param array $classNameToFileMapping (Reference to array) All values are appended to this array.
387 * @param string $path Path which should be crawled
388 * @param string $excludeRegularExpression Exclude regular expression, to exclude certain files from being processed
389 * @param string $valueWrap Wrap for the file name
390 * @return void
391 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0
392 */
393 static protected function buildAutoloadRegistryForSinglePath(&$classNameToFileMapping, $path, $excludeRegularExpression = '', $valueWrap = '\'|\'') {
394 // if (file_exists($path . 'Classes/')) {
395 // return "<b>This appears to be a new-style extension which has its PHP classes inside the Classes/ subdirectory. It is not needed to generate the autoload registry for these extensions.</b>";
396 // }
397 $extensionFileNames = t3lib_div::removePrefixPathFromList(t3lib_div::getAllFilesAndFoldersInPath(array(), $path, 'php', FALSE, 99, $excludeRegularExpression), $path);
398
399 foreach ($extensionFileNames as $extensionFileName) {
400 $classNamesInFile = self::extractClassNames($path . $extensionFileName);
401 if (!count($classNamesInFile)) continue;
402 foreach ($classNamesInFile as $className) {
403 $classNameToFileMapping[strtolower($className)] = str_replace('|', $extensionFileName, $valueWrap);
404 }
405 }
406 }
407
408 /**
409 * Extracts class names from the given file.
410 *
411 * @param string $filePath File path (absolute)
412 * @return array Class names
413 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0
414 */
415 static protected function extractClassNames($filePath) {
416 $fileContent = php_strip_whitespace($filePath);
417 $classNames = array();
418 if (FALSE) {
419 $tokens = token_get_all($fileContent);
420 while(1) {
421 // look for "class" or "interface"
422 $token = self::findToken($tokens, array(T_ABSTRACT, T_CLASS, T_INTERFACE));
423 // fetch "class" token if "abstract" was found
424 if ($token === 'abstract') {
425 $token = self::findToken($tokens, array(T_CLASS));
426 }
427 if ($token === false) {
428 // end of file
429 break;
430 }
431 // look for the name (a string) skipping only whitespace and comments
432 $token = self::findToken($tokens, array(T_STRING), array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT));
433 if ($token === false) {
434 // unexpected end of file or token: remove found names because of parse error
435 t3lib_div::sysLog('Parse error in "' . $filePath. '".', 'Core', 2);
436 $classNames = array();
437 break;
438 }
439 $token = t3lib_div::strtolower($token);
440 // exclude XLASS classes
441 if (strncmp($token, 'ux_', 3)) {
442 $classNames[] = $token;
443 }
444 }
445 } else {
446 // TODO: parse PHP - skip coments and strings, apply regexp only on the remaining PHP code
447 $matches = array();
448 preg_match_all('/^[ \t]*(?:(?:abstract|final)?[ \t]*(?:class|interface))[ \t\n\r]+([a-zA-Z][a-zA-Z_0-9]*)/mS', $fileContent, $matches);
449 $classNames = array_map('t3lib_div::strtolower', $matches[1]);
450 }
451 return $classNames;
452 }
453
454 /**
455 * Find tokens in the tokenList
456 *
457 * @param array $tokenList list of tokens as returned by token_get_all()
458 * @param array $wantedToken the tokens to be found
459 * @param array $intermediateTokens optional: list of tokens that are allowed to skip when looking for the wanted token
460 * @return mixed
461 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0
462 */
463 static protected function findToken(array &$tokenList, array $wantedTokens, array $intermediateTokens = array()) {
464 $skipAllTokens = count($intermediateTokens) ? false : true;
465
466 $returnValue = false;
467 // Iterate with while since we need the current array position:
468 foreach ($tokenList as $token) {
469 // parse token (see http://www.php.net/manual/en/function.token-get-all.php for format of token list)
470 if (is_array($token)) {
471 list($id, $text) = $token;
472 } else {
473 $id = $text = $token;
474 }
475 if (in_array($id, $wantedTokens)) {
476 $returnValue = $text;
477 break;
478 }
479 // look for another token
480 if ($skipAllTokens || in_array($id, $intermediateTokens)) {
481 continue;
482 }
483 break;
484 }
485 return $returnValue;
486 }
487
488 /**
489 * Determines the plugin namespace of the specified plugin (defaults to "tx_[extensionname]_[pluginname]")
490 * If plugin.tx_$pluginSignature.view.pluginNamespace is set, this value is returned
491 * If pluginNamespace is not specified "tx_[extensionname]_[pluginname]" is returned.
492 *
493 * @param string $extensionName name of the extension to retrieve the namespace for
494 * @param string $pluginName name of the plugin to retrieve the namespace for
495 * @return string plugin namespace
496 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0 - Use Tx_Extbase_Service_ExtensionService instead
497 */
498 static public function getPluginNamespace($extensionName, $pluginName) {
499 t3lib_div::logDeprecatedFunction();
500 $extensionService = self::getExtensionService();
501 return $extensionService->getPluginNamespace($extensionName, $pluginName);
502 }
503
504 /**
505 * Iterates through the global TypoScript configuration and returns the name of the plugin
506 * that matches specified extensionName, controllerName and actionName.
507 * If no matching plugin was found, NULL is returned.
508 * If more than one plugin matches and the current plugin is not configured to handle the action,
509 * an Exception will be thrown
510 *
511 * @param string $extensionName name of the target extension (UpperCamelCase)
512 * @param string $controllerName name of the target controller (UpperCamelCase)
513 * @param string $actionName name of the target action (lowerCamelCase)
514 * @return string name of the target plugin (UpperCamelCase) or NULL if no matching plugin configuration was found
515 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0 - Use Tx_Extbase_Service_ExtensionService instead
516 */
517 static public function getPluginNameByAction($extensionName, $controllerName, $actionName) {
518 t3lib_div::logDeprecatedFunction();
519 $extensionService = self::getExtensionService();
520 return $extensionService->getPluginNameByAction($extensionName, $controllerName, $actionName);
521 }
522
523 /**
524 * Checks if the given action is cacheable or not.
525 *
526 * @param string $extensionName Name of the target extension, without underscores
527 * @param string $pluginName Name of the target plugin
528 * @param string $controllerName Name of the target controller
529 * @param string $actionName Name of the action to be called
530 * @return boolean TRUE if the specified plugin action is cacheable, otherwise FALSE
531 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0 - Use Tx_Extbase_Service_ExtensionService instead
532 */
533 static public function isActionCacheable($extensionName, $pluginName, $controllerName, $actionName) {
534 t3lib_div::logDeprecatedFunction();
535 $extensionService = self::getExtensionService();
536 return $extensionService->isActionCacheable($extensionName, $pluginName, $controllerName, $actionName);
537 }
538
539 /**
540 * Determines the target page of the specified plugin.
541 * If plugin.tx_$pluginSignature.view.defaultPid is set, this value is used as target page id
542 * If defaultPid is set to "auto", a the target pid is determined by loading the tt_content record that contains this plugin
543 * If the page could not be determined, NULL is returned
544 * If defaultPid is "auto" and more than one page contains the specified plugin, an Exception is thrown
545 *
546 * @param string $extensionName name of the extension to retrieve the target PID for
547 * @param string $pluginName name of the plugin to retrieve the target PID for
548 * @return integer uid of the target page or NULL if target page could not be determined
549 * @deprecated since Extbase 1.4.0; will be removed in Extbase 6.0 - Use Tx_Extbase_Service_ExtensionService instead
550 */
551 static public function getTargetPidByPlugin($extensionName, $pluginName) {
552 t3lib_div::logDeprecatedFunction();
553 $extensionService = self::getExtensionService();
554 return $extensionService->getTargetPidByPlugin($extensionName, $pluginName);
555 }
556 }
557
558 ?>