Skip to content

Instantly share code, notes, and snippets.

@PSchwalkowski
Created May 19, 2017 06:12
Show Gist options
  • Save PSchwalkowski/ff47f5286870e0cdba4f819107a2dbcb to your computer and use it in GitHub Desktop.
Save PSchwalkowski/ff47f5286870e0cdba4f819107a2dbcb to your computer and use it in GitHub Desktop.
TYPO3 FlexForm utility to speed up development
<?php
namespace PS\Theme\Utility;
/**
* Utilities which should help to manage flexforms
*/
class FlexForm {
/**
* Register new flexform
* WARNING! It will override existing one if exists
*
* @param string $extKey extension key
* @param string $pluginName name of plugin
* @param string $flexFormFile name of flexform file, optional
* @return void
*/
public static function registerFlexForm($extKey, $pluginName, string $flexFormFile = null) {
$extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extKey);
$pluginSignature = implode('_', [strtolower($extensionName), strtolower($pluginName)]);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
if (!$flexFormFile)
$flexFormFile = $pluginName;
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:' . $extKey . '/Configuration/FlexForms/' . $flexFormFile . '.xml'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment