/**
  * Return the SQL String for all registered smart objects
  *
  * @return string
  */
 public static function getSmartObjectRegisterSql()
 {
     $informationService = SmartObjectInformationService::getInstance();
     $register = SmartObjectRegister::getRegister();
     $output = [];
     foreach ($register as $modelName) {
         $output[] = $informationService->getDatabaseInformation($modelName);
     }
     return implode(LF, $output);
 }
 /**
  * Find table and model information for the given extension key
  *
  * @param string $extensionKey
  *
  * @return array
  */
 protected function findTableAndModelInformationForExtension($extensionKey)
 {
     $information = [];
     $register = SmartObjectRegister::getRegister();
     foreach ($register as $class) {
         $parts = ClassNamingUtility::explodeObjectModelName($class);
         if (GeneralUtility::camelCaseToLowerCaseUnderscored($parts['extensionName']) === $extensionKey) {
             if (ModelUtility::getTableNameByModelReflectionAnnotation($class) === '') {
                 $modelInformation = SmartObjectInformationService::getInstance()->getCustomModelFieldTca($class);
                 $information[] = ['table' => ModelUtility::getTableNameByModelName($class), 'properties' => array_keys($modelInformation)];
             }
         }
     }
     return $information;
 }
 /**
  * Check if the given file is already existing
  *
  * @param $path
  * @param $modelClass
  *
  * @return void
  */
 protected function checkCshFile($path, $modelClass)
 {
     if (is_file($path)) {
         return;
     }
     $dir = PathUtility::dirname($path);
     if (!is_dir($dir)) {
         GeneralUtility::mkdir_deep($dir);
     }
     $information = SmartObjectInformationService::getInstance()->getCustomModelFieldTca($modelClass);
     $properties = array_keys($information);
     $templatePath = 'Resources/Private/Templates/ContextSensitiveHelp/LanguageDescription.xml';
     $standaloneView = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $standaloneView->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('autoloader', $templatePath));
     $standaloneView->assign('properties', $properties);
     $content = $standaloneView->render();
     FileUtility::writeFileAndCreateFolder($path, $content);
 }
Exemple #4
0
 /**
  * Get the default TCA incl. smart object fields.
  * Add missing fields to the existing TCA structure.
  *
  * @param string $extensionKey
  * @param string $tableName
  *
  * @return array
  */
 public static function getTcaOverrideInformation($extensionKey, $tableName)
 {
     $return = isset($GLOBALS['TCA'][$tableName]) ? $GLOBALS['TCA'][$tableName] : [];
     $classNames = SmartObjectRegister::getRegister();
     $informationService = SmartObjectInformationService::getInstance();
     foreach ($classNames as $className) {
         if (ClassNamingUtility::getExtensionKeyByModel($className) !== $extensionKey) {
             continue;
         }
         if (self::getTableNameByModelReflectionAnnotation($className) === $tableName) {
             $additionalTca = $informationService->getCustomModelFieldTca($className);
             foreach ($additionalTca as $fieldName => $configuration) {
                 if (!isset($return['columns'][$fieldName])) {
                     $return['columns'][$fieldName] = $configuration;
                 }
             }
         }
     }
     return $return;
 }