2 namespace TYPO3\CMS\Extbase\Utility;
45 public static function configurePlugin($extensionName, $pluginName, array $controllerActions, array $nonCacheableControllerActions = array(), $pluginType = self::PLUGIN_TYPE_PLUGIN)
47 self::checkPluginNameFormat($pluginName);
48 self::checkExtensionNameFormat($extensionName);
52 $delimiterPosition = strrpos($extensionName,
'.');
53 if ($delimiterPosition !==
false) {
54 $vendorName = str_replace(
'.',
'\\', substr($extensionName, 0, $delimiterPosition));
55 $extensionName = substr($extensionName, $delimiterPosition + 1);
57 if (!empty($vendorName)) {
58 self::checkVendorNameFormat($vendorName, $extensionName);
61 $extensionName = str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $extensionName)));
63 $pluginSignature = strtolower($extensionName .
'_' . $pluginName);
64 if (!is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName])) {
65 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName] = array();
67 foreach ($controllerActions as $controllerName => $actionsList) {
68 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName][
'controllers'][$controllerName] = array(
'actions' => \TYPO3\CMS\Core\Utility\
GeneralUtility::trimExplode(
',', $actionsList));
69 if (!empty($nonCacheableControllerActions[$controllerName])) {
70 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName][
'controllers'][$controllerName][
'nonCacheableActions'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
',', $nonCacheableControllerActions[$controllerName]);
74 switch ($pluginType) {
75 case self::PLUGIN_TYPE_PLUGIN:
76 $pluginContent = trim(
'
77 tt_content.list.20.' . $pluginSignature .
' = USER
78 tt_content.list.20.' . $pluginSignature .
' {
79 userFunc = TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run
80 extensionName = ' . $extensionName .
'
81 pluginName = ' . $pluginName . (null !== $vendorName ? (
"\n\t" .
'vendorName = ' . $vendorName) :
'') .
'
84 case self::PLUGIN_TYPE_CONTENT_ELEMENT:
85 $pluginContent = trim(
'
86 tt_content.' . $pluginSignature .
' = COA
87 tt_content.' . $pluginSignature .
' {
91 userFunc = TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run
92 extensionName = ' . $extensionName .
'
93 pluginName = ' . $pluginName . (null !== $vendorName ? (
"\n\t\t" .
'vendorName = ' . $vendorName) :
'') .
'
98 throw new \InvalidArgumentException(
'The pluginType "' . $pluginType .
'" is not suported', 1289858856);
100 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName][
'pluginType'] = $pluginType;
101 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($extensionName,
'setup',
'
102 # Setting ' . $extensionName .
' plugin TypoScript
103 ' . $pluginContent,
'defaultContentRendering');
117 public static function registerPlugin($extensionName, $pluginName, $pluginTitle, $pluginIconPathAndFilename = null)
119 self::checkPluginNameFormat($pluginName);
120 self::checkExtensionNameFormat($extensionName);
122 $delimiterPosition = strrpos($extensionName,
'.');
123 if ($delimiterPosition !==
false) {
124 $extensionName = substr($extensionName, $delimiterPosition + 1);
126 $extensionName = str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $extensionName)));
127 $pluginSignature = strtolower($extensionName) .
'_' . strtolower($pluginName);
131 $extensionKey = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
134 $pluginType = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName][
'pluginType'])
135 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'plugins'][$pluginName][
'pluginType']
138 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
139 array($pluginTitle, $pluginSignature, $pluginIconPathAndFilename),
156 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
157 return \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::configureModule($moduleSignature, $modulePath);
173 public static function registerModule($extensionName, $mainModuleName =
'', $subModuleName =
'', $position =
'', array $controllerActions = array(), array $moduleConfiguration = array())
175 self::checkExtensionNameFormat($extensionName);
179 if (
false !== $delimiterPosition = strrpos($extensionName,
'.')) {
180 $vendorName = str_replace(
'.',
'\\', substr($extensionName, 0, $delimiterPosition));
181 $extensionName = substr($extensionName, $delimiterPosition + 1);
183 if (!empty($vendorName)) {
184 self::checkVendorNameFormat($vendorName, $extensionName);
187 $extensionKey = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
188 $extensionName = str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $extensionName)));
189 $defaultModuleConfiguration = array(
191 'icon' =>
'EXT:extbase/ext_icon.png',
193 'extRelPath' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($extensionKey) .
'Classes/'
195 if ($mainModuleName !==
'' && !array_key_exists($mainModuleName,
$GLOBALS[
'TBE_MODULES'])) {
196 $mainModuleName = $extensionName . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($mainModuleName);
198 $mainModuleName = $mainModuleName !==
'' ? $mainModuleName :
'web';
201 if ($mainModuleName ===
'web') {
202 $defaultModuleConfiguration[
'navigationComponentId'] =
'typo3-pagetree';
204 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultModuleConfiguration, $moduleConfiguration);
205 $moduleConfiguration = $defaultModuleConfiguration;
206 $moduleSignature = $mainModuleName;
207 if ($subModuleName !==
'') {
208 $subModuleName = $extensionName . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($subModuleName);
209 $moduleSignature .=
'_' . $subModuleName;
211 $moduleConfiguration[
'name'] = $moduleSignature;
212 if (null !== $vendorName) {
213 $moduleConfiguration[
'vendorName'] = $vendorName;
215 $moduleConfiguration[
'extensionName'] = $extensionName;
216 $moduleConfiguration[
'configureModuleFunction'] = array(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::class,
'configureModule');
217 $GLOBALS[
'TBE_MODULES'][
'_configuration'][$moduleSignature] = $moduleConfiguration;
218 if (!is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'modules'][$moduleSignature])) {
219 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'modules'][$moduleSignature] = array();
221 foreach ($controllerActions as $controllerName => $actions) {
222 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][$extensionName][
'modules'][$moduleSignature][
'controllers'][$controllerName] = array(
226 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule($mainModuleName, $subModuleName, $position);
238 if (!is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'typeConverters'])) {
239 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'typeConverters'] = array();
241 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'typeConverters'][] = $typeConverterClassName;
254 if (preg_match(
'/^[A-Z]/', $vendorName) !== 1) {
255 \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
'The vendor name from tx_' . $extensionName .
' must begin with a capital letter.');
268 if (empty($extensionName)) {
269 throw new \InvalidArgumentException(
'The extension name must not be empty', 1239891990);
282 if (empty($pluginName)) {
283 throw new \InvalidArgumentException(
'The plugin name must not be empty', 1239891988);