TYPO3 CMS  TYPO3_6-2
ExtensionService.php
Go to the documentation of this file.
1 <?php
3 
20 
21  const PLUGIN_TYPE_PLUGIN = 'list_type';
22  const PLUGIN_TYPE_CONTENT_ELEMENT = 'CType';
23 
28  protected $objectManager;
29 
35 
40  protected $targetPidPluginCache = array();
41 
51  public function getPluginNamespace($extensionName, $pluginName) {
52  $pluginSignature = strtolower($extensionName . '_' . $pluginName);
53  $defaultPluginNamespace = 'tx_' . $pluginSignature;
54  $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
55  if (!isset($frameworkConfiguration['view']['pluginNamespace']) || empty($frameworkConfiguration['view']['pluginNamespace'])) {
56  return $defaultPluginNamespace;
57  }
58  return $frameworkConfiguration['view']['pluginNamespace'];
59  }
60 
74  public function getPluginNameByAction($extensionName, $controllerName, $actionName) {
75  $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
76  // check, whether the current plugin is configured to handle the action
77  if ($extensionName === $frameworkConfiguration['extensionName']) {
78  if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName]) && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['actions'])) {
79  return $frameworkConfiguration['pluginName'];
80  }
81  }
82  if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'])) {
83  return NULL;
84  }
85  $pluginNames = array();
86  foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'] as $pluginName => $pluginConfiguration) {
87  if (!is_array($pluginConfiguration['controllers'])) {
88  continue;
89  }
90  foreach ($pluginConfiguration['controllers'] as $pluginControllerName => $pluginControllerActions) {
91  if (strtolower($pluginControllerName) !== strtolower($controllerName)) {
92  continue;
93  }
94  if (in_array($actionName, $pluginControllerActions['actions'])) {
95  $pluginNames[] = $pluginName;
96  }
97  }
98  }
99  if (count($pluginNames) > 1) {
100  throw new \TYPO3\CMS\Extbase\Exception('There is more than one plugin that can handle this request (Extension: "' . $extensionName . '", Controller: "' . $controllerName . '", action: "' . $actionName . '"). Please specify "pluginName" argument', 1280825466);
101  }
102  return count($pluginNames) > 0 ? $pluginNames[0] : NULL;
103  }
104 
114  public function isActionCacheable($extensionName, $pluginName, $controllerName, $actionName) {
115  $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
116  if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName]) && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]) && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions']) && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])) {
117  return FALSE;
118  }
119  return TRUE;
120  }
121 
134  public function getTargetPidByPlugin($extensionName, $pluginName) {
135  $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
136  if (!isset($frameworkConfiguration['view']['defaultPid']) || empty($frameworkConfiguration['view']['defaultPid'])) {
137  return NULL;
138  }
139  $pluginSignature = strtolower($extensionName . '_' . $pluginName);
140  if ($frameworkConfiguration['view']['defaultPid'] === 'auto') {
141  if (!array_key_exists($pluginSignature, $this->targetPidPluginCache)) {
142  $pages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid', 'tt_content', 'list_type=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($pluginSignature, 'tt_content') . ' AND CType="list"' . $GLOBALS['TSFE']->sys_page->enableFields('tt_content') . ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid, '', '', 2);
143  if (count($pages) > 1) {
144  throw new \TYPO3\CMS\Extbase\Exception('There is more than one "' . $pluginSignature . '" plugin in the current page tree. Please remove one plugin or set the TypoScript configuration "plugin.tx_' . $pluginSignature . '.view.defaultPid" to a fixed page id', 1280773643);
145  }
146  $this->targetPidPluginCache[$pluginSignature] = count($pages) > 0 ? $pages[0]['pid'] : NULL;
147  }
148  return $this->targetPidPluginCache[$pluginSignature];
149 
150  }
151  return (int)$frameworkConfiguration['view']['defaultPid'];
152  }
153 
161  public function getDefaultControllerNameByPlugin($extensionName, $pluginName) {
162  if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'])) {
163  return NULL;
164  }
165  $controllers = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'];
166  return key($controllers);
167  }
168 
177  public function getDefaultActionNameByPluginAndController($extensionName, $pluginName, $controllerName) {
178  if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'][$controllerName]['actions'])) {
179  return NULL;
180  }
181  $actions = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'][$controllerName]['actions'];
182  return current($actions);
183  }
184 
192  public function getTargetPageTypeByFormat($extensionName, $format) {
193  $targetPageType = 0;
194  $settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $extensionName);
195  $formatToPageTypeMapping = isset($settings['view']['formatToPageTypeMapping']) ? $settings['view']['formatToPageTypeMapping'] : array();
196  if (is_array($formatToPageTypeMapping) && array_key_exists($format, $formatToPageTypeMapping)) {
197  $targetPageType = (int)$formatToPageTypeMapping[$format];
198  }
199  return $targetPageType;
200  }
201 
202 }
getPluginNameByAction($extensionName, $controllerName, $actionName)
getTargetPidByPlugin($extensionName, $pluginName)
getPluginNamespace($extensionName, $pluginName)
isActionCacheable($extensionName, $pluginName, $controllerName, $actionName)
getTargetPageTypeByFormat($extensionName, $format)
getDefaultActionNameByPluginAndController($extensionName, $pluginName, $controllerName)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
getDefaultControllerNameByPlugin($extensionName, $pluginName)