Example #1
0
 /**
  * Check and create the TCA information
  * disable this for better performance
  */
 public static function checkAndCreateTcaInformation()
 {
     $register = SmartObjectRegister::getRegister();
     $baseTemplatePath = ExtensionManagementUtility::extPath('autoloader', 'Resources/Private/Templates/TcaFiles/');
     $defaultTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Default.tmpl');
     $overrideTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Override.tmpl');
     $search = ['__modelName__', '__tableName__', '__extensionKey__'];
     foreach ($register as $model) {
         $extensionKey = ClassNamingUtility::getExtensionKeyByModel($model);
         $basePath = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/TCA/';
         $tableName = ModelUtility::getTableNameByModelReflectionAnnotation($model);
         if ($tableName !== '') {
             $tcaFileName = $basePath . 'Overrides/' . $tableName . '.php';
             $template = $overrideTemplate;
         } else {
             $tableName = ModelUtility::getTableNameByModelName($model);
             $tcaFileName = $basePath . $tableName . '.php';
             $template = $defaultTemplate;
         }
         if (!is_file($tcaFileName)) {
             $replace = [str_replace('\\', '\\\\', $model), $tableName, $extensionKey];
             $content = str_replace($search, $replace, $template);
             FileUtility::writeFileAndCreateFolder($tcaFileName, $content);
         }
     }
 }
 /**
  * Get the smart objects for the given extension
  *
  * @param $extensionKey
  *
  * @return mixed
  */
 private function getSmartObjectsForExtensionKey($extensionKey)
 {
     $smartObjects = SmartObjectRegister::getRegister();
     $extensionObjects = [];
     foreach ($smartObjects as $className) {
         $objectExtension = ClassNamingUtility::getExtensionKeyByModel($className);
         if ($objectExtension === $extensionKey) {
             $extensionObjects[] = $className;
         }
     }
     return $extensionObjects;
 }
Example #3
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;
 }