/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $pluginInformation = []; $controllerPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Controller/'; $controllers = FileUtility::getBaseFilesRecursivelyInDir($controllerPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($controllers as $controller) { $controllerName = $loader->getVendorName() . '\\' . $extKey . '\\Controller\\' . str_replace('/', '\\', $controller); if (!$loader->isInstantiableClass($controllerName)) { continue; } $controllerKey = str_replace('/', '\\', $controller); $controllerKey = str_replace('Controller', '', $controllerKey); $methods = ReflectionUtility::getPublicMethods($controllerName); foreach ($methods as $method) { /** @var $method \TYPO3\CMS\Extbase\Reflection\MethodReflection */ if ($method->isTaggedWith('plugin')) { $pluginKeys = GeneralUtility::trimExplode(' ', implode(' ', $method->getTagValues('plugin')), true); $actionName = str_replace('Action', '', $method->getName()); foreach ($pluginKeys as $pluginKey) { $pluginInformation = $this->addPluginInformation($pluginInformation, $pluginKey, $controllerKey, $actionName, $method->isTaggedWith('noCache')); } } } } return $pluginInformation; }
/** * Call this function at the end of your ext_tables.php to autoregister the flexforms * of the extension to the given plugins. * * @return void */ public static function flexFormAutoLoader() { global $TCA, $_EXTKEY; $_extConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['nn_address']); $FlexFormPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/FlexForms/'; $extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY); $FlexForms = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($FlexFormPath, 'xml'); foreach ($FlexForms as $FlexForm) { if (preg_match("/^Model_(.*)\$/", $FlexForm)) { continue; } $fileKey = str_replace('.xml', '', $FlexForm); $pluginSignature = strtolower($extensionName . '_' . $fileKey); #$TCA['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout,select_key,recursive'; $TCA['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'select_key,recursive'; $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; $fileFlexForm = 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/' . $fileKey . '.xml'; // Any flexform dir in extension config set? if ($_extConfig['flexFormPlugin'] != '') { if (is_dir(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($_extConfig['flexFormPlugin']))) { // modify the relative path $path = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($_extConfig['flexFormPlugin']); $path = preg_match('/^(.*)\\/$/', $path) ? $path : $path . '/'; $fileFlexForm = 'FILE:' . $path . $fileKey . '.xml'; } } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, $fileFlexForm); } }
/** * A utility method which calls ExtensionManagementUtility::addPiFlexFormValue * * This method performs the necessary string manipulations which are necessary * for extbase based extensions. * * @param string $extensionKey Mostly $_EXTKEY * @param string $pluginName Same value which is passed into * Tx_Extbase_Utility_Extension::registerPlugin() as a * second value * @param string $flexformFile Last part of the flexform file * without leading slash * * @return void * * @api */ public static function addPluginFlexform($extensionKey, $pluginName, $flexformFile) { $extensionName = GeneralUtility::underscoredToUpperCamelCase($extensionKey); $pluginSignature = strtolower($extensionName . '_' . $pluginName); $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, self::getFlexformFileReference($extensionKey, $flexformFile)); }
/** * Returns a package instance. * * @param string $packagesBasePath the base install path of packages, * @param string $packagePath path to package, relative to base path * @param string $packageKey key / name of the package * @param string $classesPath path to the classes directory, relative to the package path * @param string $manifestPath path to the package's Composer manifest, relative to package path, defaults to same path * @return \TYPO3\Flow\Package\PackageInterface * @throws \TYPO3\Flow\Package\Exception\CorruptPackageException */ public function create($packagesBasePath, $packagePath, $packageKey, $classesPath, $manifestPath = '') { $packagePath = Files::getNormalizedPath(Files::concatenatePaths(array($packagesBasePath, $packagePath))); $packageClassPathAndFilename = Files::concatenatePaths(array($packagePath, 'Classes/' . str_replace('.', '/', $packageKey) . '/Package.php')); $alternativeClassPathAndFilename = Files::concatenatePaths(array($packagePath, 'Classes/Package.php')); $packageClassPathAndFilename = @file_exists($alternativeClassPathAndFilename) ? $alternativeClassPathAndFilename : $packageClassPathAndFilename; if (@file_exists($packageClassPathAndFilename)) { require_once $packageClassPathAndFilename; if (substr($packagePath, 0, strlen(PATH_typo3)) === PATH_typo3 && strpos($packageKey, '.') === FALSE) { //TODO Remove this exception once the systextension are renamed to proper Flow naming scheme packages $packageClassName = 'TYPO3\\CMS\\' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($packageKey) . '\\Package'; } else { $packageClassName = str_replace('.', '\\', $packageKey) . '\\Package'; } if (!class_exists($packageClassName, FALSE)) { throw new \TYPO3\Flow\Package\Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class called "%s".', $packageKey, $packageClassPathAndFilename, $packageClassName), 1327587092); } } else { $emConfPath = Files::concatenatePaths(array($packagePath, 'ext_emconf.php')); $packageClassName = @file_exists($emConfPath) ? 'TYPO3\\CMS\\Core\\Package\\Package' : 'TYPO3\\Flow\\Package\\Package'; } /** @var $package \TYPO3\Flow\Package\PackageInterface */ $package = new $packageClassName($this->packageManager, $packageKey, $packagePath, $classesPath, $manifestPath); return $package; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $slots = []; $slotPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Slots/'; $slotClasses = FileUtility::getBaseFilesInDir($slotPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); foreach ($slotClasses as $slot) { $slotClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Slots\\' . $slot; if (!$autoLoader->isInstantiableClass($slotClass)) { continue; } $methods = ReflectionUtility::getPublicMethods($slotClass); foreach ($methods as $methodReflection) { /** @var MethodReflection $methodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName']); foreach ($tagConfiguration['signalClass'] as $key => $signalClass) { if (!isset($tagConfiguration['signalName'][$key])) { continue; } $slots[] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()]; } } } return $slots; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $hooks = []; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Hooks/'; $files = FileUtility::getBaseFilesInDir($folder, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($files as $hookFile) { $hookClass = $loader->getVendorName() . '\\' . $extKey . '\\Hooks\\' . $hookFile; if (!$loader->isInstantiableClass($hookClass)) { continue; } $classReflection = ReflectionUtility::createReflectionClass($hookClass); // add class hook $tagConfiguration = ReflectionUtility::getTagConfiguration($classReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass]; } // add method hooks foreach ($classReflection->getMethods(MethodReflection::IS_PUBLIC) as $methodReflection) { /** @var $methodReflection \TYPO3\CMS\Extbase\Reflection\MethodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass . '->' . $methodReflection->getName()]; } } } return $hooks; }
/** * Is {outer.{inner}} a datetime? * * @param object $obj * @param string $prop Property * @return bool */ public function render($obj, $prop) { $mixed = NULL; if (is_object($obj) && method_exists($obj, 'get' . GeneralUtility::underscoredToUpperCamelCase($prop))) { $mixed = $obj->{'get' . GeneralUtility::underscoredToUpperCamelCase($prop)}(); } return method_exists($mixed, 'getTimestamp'); }
/** * Solution for {outer.{inner}} problem with variables in fluid * * @param object $obj * @param string $prop * @return string */ public function render($obj, $prop) { if (is_object($obj) && method_exists($obj, 'get' . GeneralUtility::underscoredToUpperCamelCase($prop))) { return $obj->{'get' . GeneralUtility::underscoredToUpperCamelCase($prop)}(); } elseif (is_array($obj)) { if (array_key_exists($prop, $obj)) { return $obj[$prop]; } } return NULL; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $servicePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Service/Soap/'; $serviceClasses = FileUtility::getBaseFilesRecursivelyInDir($servicePath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); $info = []; foreach ($serviceClasses as $service) { $serviceClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Service\\Soap\\' . $service; $info[lcfirst($service)] = $serviceClass; } return $info; }
/** * @param \TYPO3\CMS\Core\Resource\FileReference $originalResource */ public function setOriginalResource(\TYPO3\CMS\Core\Resource\FileReference $originalResource) { $this->originalResource = $originalResource; # Absorb properties from original resource, because otherwise we'll get an empty sys_file_reference row. $originalResourceProperties = $originalResource->getReferenceProperties(); foreach ($originalResourceProperties as $propertyName => $propertyValue) { $setter = 'set' . GeneralUtility::underscoredToUpperCamelCase($propertyName); if (method_exists($this, $setter)) { $this->{$setter}($propertyValue); } } }
/** * Render the content Element via ExtBase */ public function indexAction() { $extensionKey = $this->settings['extensionKey']; $vendorName = $this->settings['vendorName']; $name = $this->settings['contentElement']; $data = $this->configurationManager->getContentObject()->data; $camelCaseExtKey = GeneralUtility::underscoredToUpperCamelCase($extensionKey); $targetObject = $vendorName . '\\' . $camelCaseExtKey . '\\Domain\\Model\\Content\\' . $name; $model = ModelUtility::getModel($targetObject, $data); $view = $this->createStandaloneView(); $view->assignMultiple(['data' => $data, 'object' => $model, 'settings' => $this->settings]); return $view->render(); }
public function getRecurranceSubtype($config) { $type = trim($config['row']['recurrance_type']); if (empty($type)) { return; } $className = 'Tx_CzSimpleCal_Recurrance_Type_' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($type); $callback = array($className, 'getSubtypes'); if (!class_exists($className) || !is_callable($callback)) { return; } $config['items'] = call_user_func($callback); }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $classes = []; $converterPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Property/TypeConverter/'; $converterClasses = FileUtility::getBaseFilesRecursivelyInDir($converterPath, 'php', true); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); foreach ($converterClasses as $converterClass) { $converterClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Property\\TypeConverter\\' . str_replace('/', '\\', $converterClass); if ($autoLoader->isInstantiableClass($converterClass)) { $classes[] = $converterClass; } } return $classes; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $classNames = []; $alternativeImpPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/AlternativeImplementations/'; $alternativeClasses = FileUtility::getBaseFilesInDir($alternativeImpPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($alternativeClasses as $aic) { $aicClass = $loader->getVendorName() . '\\' . $extKey . '\\AlternativeImplementations\\' . $aic; if (!$loader->isInstantiableClass($aicClass)) { continue; } $classNames[] = ['originalName' => ReflectionUtility::getParentClassName($aicClass), 'alternativeClassName' => $aicClass]; } return $classNames; }
/** * @param $pluginName * @param $pluginTitle * @param null $flexFormClass */ protected static function registerPlugin($pluginName, $pluginTitle, $flexFormClass = null) { ExtensionUtility::registerPlugin('BERGWERK.' . self::$_extKey, $pluginName, $pluginTitle); if (empty($flexFormClass)) { return; } /** @var FlexForm $flexFormInstance */ $flexFormInstance = new $flexFormClass(); if (!$flexFormInstance instanceof FlexForm) { return; } $flexForm = $flexFormInstance->render(); $pluginSignature = strtolower(GeneralUtility::underscoredToUpperCamelCase(self::$_extKey)) . '_' . strtolower($pluginName); $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, $flexForm); }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $classNames = []; $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Command/'; $controllers = FileUtility::getBaseFilesInDir($commandPath, 'php'); foreach ($controllers as $controller) { if ($controller === 'AbstractCommandController') { continue; } $className = $loader->getVendorName() . '\\' . ucfirst(GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey())) . '\\Command\\' . $controller; if (!$loader->isInstantiableClass($className)) { continue; } $classNames[] = $className; } return $classNames; }
/** * @param object $item current classified object * @param string $field * @param bool $raw * @return string */ public function render($item, $field, $raw = false) { $value = ""; if ($field != "") { $getCall = "get" . GeneralUtility::underscoredToUpperCamelCase($field); if (method_exists($item, $getCall)) { if ($raw) { $value = $item->{$getCall}(); } else { $value = $item->{$getCall}(true); } } elseif (is_array($item)) { $value = $item[$field]; } } return $value; }
/** * Prepare the content object loader * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $loaderInformation = []; $modelPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Domain/Model/Content/'; $models = FileUtility::getBaseFilesInDir($modelPath, 'php'); if ($models) { TranslateUtility::assureLabel('tt_content.' . $loader->getExtensionKey() . '.header', $loader->getExtensionKey(), $loader->getExtensionKey() . ' (Header)'); } foreach ($models as $model) { $key = GeneralUtility::camelCaseToLowerCaseUnderscored($model); $className = $loader->getVendorName() . '\\' . ucfirst(GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey())) . '\\Domain\\Model\\Content\\' . $model; if (!$loader->isInstantiableClass($className)) { continue; } $fieldConfiguration = []; $richTextFields = []; // create labels in the ext_tables run, to have a valid DatabaseConnection if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel('wizard.' . $key, $loader->getExtensionKey(), $key . ' (Title)'); TranslateUtility::assureLabel('wizard.' . $key . '.description', $loader->getExtensionKey(), $key . ' (Description)'); $fieldConfiguration = $this->getClassPropertiesInLowerCaseUnderscored($className); $defaultFields = $this->getDefaultTcaFields(); $fieldConfiguration = array_diff($fieldConfiguration, $defaultFields); // RTE manipulation $classReflection = ReflectionUtility::createReflectionClass($className); foreach ($classReflection->getProperties() as $property) { /** @var $property PropertyReflection */ if ($property->isTaggedWith('enableRichText')) { $search = array_search(GeneralUtility::camelCaseToLowerCaseUnderscored($property->getName()), $fieldConfiguration); if ($search !== false) { if (GeneralUtility::compat_version('7.0')) { $richTextFields[] = $fieldConfiguration[$search]; } else { $fieldConfiguration[$search] .= ';;;richtext:rte_transform[flag=rte_enabled|mode=ts_css]'; } } } } } $entry = ['fieldConfiguration' => implode(',', $fieldConfiguration), 'richTextFields' => $richTextFields, 'modelClass' => $className, 'model' => $model, 'icon' => IconUtility::getByModelName($className), 'iconExt' => IconUtility::getByModelName($className, true), 'noHeader' => $this->isTaggedWithNoHeader($className), 'tabInformation' => ReflectionUtility::getFirstTagValue($className, 'wizardTab')]; SmartObjectRegister::register($entry['modelClass']); $loaderInformation[$key] = $entry; } $this->checkAndCreateDummyTemplates($loaderInformation, $loader); return $loaderInformation; }
/** * Returns an array of class name parts including vendor, extension * and domain model * * Example: * array( * Vendor * MyExt * MyModel * ) * * @param string $path * @param bool $convertPlural Indicates if plural resource names should be converted * @return array */ public static function getClassNamePartsForPath($path, $convertPlural = TRUE) { if (strpos($path, '_') !== FALSE) { $path = GeneralUtility::underscoredToUpperCamelCase($path); } $parts = explode(self::API_PATH_PART_SEPARATOR, $path); if (count($parts) < 3) { array_unshift($parts, ''); } if ($convertPlural && $parts) { $lastPartIndex = count($parts) - 1; $parts[$lastPartIndex] = static::singularize($parts[$lastPartIndex]); } $parts = array_map(function ($part) { return ucfirst($part); }, $parts); return $parts; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $configuration = []; $modelPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Domain/Model/'; if (!is_dir($modelPath)) { return $configuration; } $models = FileUtility::getBaseFilesInDir($modelPath, 'php'); foreach ($models as $model) { $className = $loader->getVendorName() . '\\' . ucfirst(GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey())) . '\\Domain\\Model\\' . $model; if (SmartObjectManager::isSmartObjectClass($className)) { $configuration[] = $className; } } // already add for the following processes $this->addClassesToSmartRegister($configuration); return $configuration; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $return = []; if ($type === LoaderInterface::EXT_TABLES) { return $return; } $xClassesPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Xclass/'; $xClasses = FileUtility::getBaseFilesRecursivelyInDir($xClassesPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($xClasses as $xClass) { $xclassName = $loader->getVendorName() . '\\' . $extKey . '\\Xclass\\' . str_replace('/', '\\', $xClass); if (!$loader->isInstantiableClass($xclassName)) { continue; } $return[] = ['source' => ReflectionUtility::getParentClassName($xclassName), 'target' => $xclassName]; } return $return; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $flexForms = []; $flexFormPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Configuration/FlexForms/'; // Plugins $extensionName = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); $flexFormsFiles = FileUtility::getBaseFilesInDir($flexFormPath, 'xml'); foreach ($flexFormsFiles as $fileKey) { $pluginSignature = strtolower($extensionName . '_' . $fileKey); $flexForms[] = ['pluginSignature' => $pluginSignature, 'path' => 'FILE:EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/' . $fileKey . '.xml']; } // Content $flexFormsFiles = FileUtility::getBaseFilesInDir($flexFormPath . 'Content/', 'xml'); foreach ($flexFormsFiles as $fileKey) { $contentSignature = strtolower($loader->getExtensionKey() . '_' . GeneralUtility::camelCaseToLowerCaseUnderscored($fileKey)); $flexForms[] = ['contentSignature' => $contentSignature, 'path' => 'FILE:EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Content/' . $fileKey . '.xml']; } return $flexForms; }
/** * @param string $string * @param string $case * @return string */ public function render($string = null, $case = null) { if (null === $string) { $string = $this->renderChildren(); } if ('BE' === TYPO3_MODE) { $tsfeBackup = FrontendSimulationUtility::simulateFrontendEnvironment(); } $charset = $GLOBALS['TSFE']->renderCharset; switch ($case) { case self::CASE_LOWER: $string = $GLOBALS['TSFE']->csConvObj->conv_case($charset, $string, 'toLower'); break; case self::CASE_UPPER: $string = $GLOBALS['TSFE']->csConvObj->conv_case($charset, $string, 'toUpper'); break; case self::CASE_UCWORDS: $string = ucwords($string); break; case self::CASE_UCFIRST: $string = $GLOBALS['TSFE']->csConvObj->convCaseFirst($charset, $string, 'toUpper'); break; case self::CASE_LCFIRST: $string = $GLOBALS['TSFE']->csConvObj->convCaseFirst($charset, $string, 'toLower'); break; case self::CASE_CAMELCASE: $string = GeneralUtility::underscoredToUpperCamelCase($string); break; case self::CASE_LOWERCAMELCASE: $string = GeneralUtility::underscoredToLowerCamelCase($string); break; case self::CASE_UNDERSCORED: $string = GeneralUtility::camelCaseToLowerCaseUnderscored($string); break; default: break; } if ('BE' === TYPO3_MODE) { FrontendSimulationUtility::resetFrontendEnvironment($tsfeBackup); } return $string; }
/** * build the exception timeline * * @return Tx_CzSimpleCal_Recurrance_Timeline_Exception */ protected function buildExceptionTimeline() { $exceptionTimeline = new Tx_CzSimpleCal_Recurrance_Timeline_Exception(); foreach ($this->event->getExceptions() as $exception) { $type = $exception->getRecurranceType(); if (empty($type)) { throw new RuntimeException('The recurrance_type should not be empty.'); } $className = 'Tx_CzSimpleCal_Recurrance_Type_' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($type); if (!class_exists($className)) { throw new BadMethodCallException(sprintf('The class %s does not exist for creating recurring events.', $className)); } $class = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className); if (!$class instanceof Tx_CzSimpleCal_Recurrance_Type_Base) { throw new BadMethodCallException(sprintf('The class %s does not implement Tx_CzSimpleCal_Recurrance_Type_Base.', get_class($class))); } $exceptionTimeline = $class->build($exception, $exceptionTimeline); } return $exceptionTimeline; }
/** * Fetch all modules displayed given a pid. * * @param int $pid * @return array */ public function getModulesForPid($pid = NULL) { if (!isset($this->storage[$pid])) { $modules = array(); foreach ($GLOBALS['TCA'] as $dataType => $configuration) { if (Tca::table($dataType)->isNotHidden()) { $clause = 'pid = ' . $pid; $clause .= BackendUtility::deleteClause($dataType); $record = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', $dataType, $clause); if (!empty($record)) { $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1'; $title = Tca::table($dataType)->getTitle(); $modules[$moduleName] = $title; } } } $this->storage[$pid] = $modules; } return $this->storage[$pid]; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $tsConfiguration = []; $extPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()); $baseDir = $extPath . 'Configuration/TypoScript/'; if (!is_dir($baseDir)) { return $tsConfiguration; } $typoScriptFolder = GeneralUtility::getAllFilesAndFoldersInPath([], $baseDir, '', true, 99, '(.*)\\.(.*)'); $extensionName = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($typoScriptFolder as $folder) { if (is_file($folder . 'setup.txt') || is_file($folder . 'constants.txt')) { $setupName = $extensionName . '/' . str_replace($baseDir, '', $folder); $setupName = implode(' - ', GeneralUtility::trimExplode('/', $setupName, true)); $folder = str_replace($extPath, '', $folder); $tsConfiguration[] = ['path' => $folder, 'title' => $setupName]; } } return $tsConfiguration; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array $loaderInformation */ public function prepareLoader(Loader $loader, $type) { $aspects = []; $aspectPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Aspect/'; $aspectClasses = FileUtility::getBaseFilesInDir($aspectPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($aspectClasses as $aspect) { $aspectClass = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Aspect/' . $aspect); if (!$loader->isInstantiableClass($aspectClass)) { continue; } try { $methods = ReflectionUtility::getPublicMethods($aspectClass); foreach ($methods as $methodReflection) { /** @var $methodReflection \TYPO3\CMS\Extbase\Reflection\MethodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['aspectClass', 'aspectJoinPoint', 'aspectAdvice']); foreach ($tagConfiguration['aspectClass'] as $key => $aspectClass) { if (!isset($tagConfiguration['aspectJoinPoint'][$key]) || !isset($tagConfiguration['aspectAdvice'][$key])) { continue; } $aspectClassName = trim($aspectClass, '\\'); $aspectJoinPoint = trim($tagConfiguration['aspectJoinPoint'][$key]); // check only if class exists if (!$loader->isInstantiableClass($aspectClassName)) { continue; } $aspectJpArguments = $this->getMethodArgumentsFromClassMethod($aspectClassName, $aspectJoinPoint); $aspects[] = ['aspectClassName' => $aspectClassName, 'aspectJoinPoint' => $aspectJoinPoint, 'aspectJoinPointArguments' => $aspectJpArguments, 'aspectAdvice' => trim($tagConfiguration['aspectAdvice'][$key]), 'originClassName' => $aspectClass, 'originMethodName' => $methodReflection->getName()]; } } } catch (\Exception $e) { // Class or file is not available for Aspects $aspectClassName continue; } } return $aspects; }
/** * Helper function to verify various conditions around possible mapping/inheritance configurations * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject * @param string $renderCondition * @return string */ public function render(\EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject, $renderCondition) { $content = ''; $extensionPrefix = 'Tx_' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($domainObject->getExtension()->getExtensionKey()); // an external table should have a loadable TCA configuration and the column definitions // for external tables have to be declared in ext_tables.php $isMappedToExternalTable = FALSE; // table name is only set, if the model is mapped to a table or if the domain object extends a class $tableName = $domainObject->getMapToTable(); if ($tableName && strpos($tableName, strtolower($extensionPrefix) . '_domain_model_') === FALSE) { $isMappedToExternalTable = TRUE; } switch ($renderCondition) { case 'isMappedToInternalTable': if (!$isMappedToExternalTable) { $content = $this->renderThenChild(); } else { $content = $this->renderElseChild(); } break; case 'isMappedToExternalTable': if ($isMappedToExternalTable) { $content = $this->renderThenChild(); } else { $content = $this->renderElseChild(); } break; case 'needsTypeField': if ($this->needsTypeField($domainObject, $isMappedToExternalTable)) { $content = $this->renderThenChild(); } else { $content = $this->renderElseChild(); } break; } return $content; }
/** * Function execute from the Scheduler * * @return boolean TRUE on successful execution, FALSE on error */ public function execute() { list($extensionName, $controllerName, $commandName) = explode(':', $this->commandIdentifier); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $this->injectObjectManager($objectManager); $request = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Request'); $dispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher'); $response = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response'); try { $upperCamelCaseExtensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extensionName); $upperCamelCaseControllerName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($controllerName); // TODO build class name a different way now that we have namespaces // see https://www.pivotaltracker.com/story/show/73980994 $controllerObjectName = sprintf('Tx_%s_Command_%sCommandController', $upperCamelCaseExtensionName, $upperCamelCaseControllerName); $request->setControllerCommandName($commandName); $request->setControllerObjectName($controllerObjectName); $request->setArguments((array) $this->arguments); $dispatcher->dispatch($request, $response); return TRUE; } catch (\Exception $e) { \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($e->getMessage(), $extensionName, $e->getCode()); return FALSE; } }
<?php $pluginSignature = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase('typo3_forum')) . '_pi1'; $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:typo3_forum/Configuration/FlexForms/Pi1.xml'); $pluginSignature = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase('typo3_forum')) . '_widget'; $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:typo3_forum/Configuration/FlexForms/Widgets.xml');