protected function generateTCAFiles()
 {
     // Generate TCA
     try {
         GeneralUtility::mkdir_deep($this->extensionDirectory, 'Configuration/TCA');
         $domainObjects = $this->extension->getDomainObjects();
         foreach ($domainObjects as $domainObject) {
             /**
              * @var $domainObject \EBT\ExtensionBuilder\Domain\Model\DomainObject
              */
             if (!$domainObject->getMapToTable()) {
                 $fileContents = $this->generateTCA($domainObject);
                 $this->writeFile($this->configurationDirectory . 'TCA/' . $domainObject->getDatabaseTableName() . '.php', $fileContents);
             }
         }
         $domainObjectsNeedingOverrides = array();
         foreach ($this->extension->getDomainObjectsInHierarchicalOrder() as $domainObject) {
             if ($domainObject->isMappedToExistingTable() || $domainObject->getHasChildren()) {
                 if (!isset($domainObjectsNeedingOverrides[$domainObject->getDatabaseTableName()])) {
                     $domainObjectsNeedingOverrides[$domainObject->getDatabaseTableName()] = array();
                 }
                 $domainObjectsNeedingOverrides[$domainObject->getDatabaseTableName()][] = $domainObject;
             }
         }
         $tablesNeedingTypeFields = $this->extension->getTablesForTypeFieldDefinitions();
         foreach ($domainObjectsNeedingOverrides as $tableName => $domainObjects) {
             $addRecordTypeField = in_array($tableName, $tablesNeedingTypeFields);
             $fileContents = $this->generateTCAOverride($domainObjects, $addRecordTypeField);
             $this->writeFile($this->configurationDirectory . 'TCA/Overrides/' . $tableName . '.php', $fileContents);
         }
     } catch (\Exception $e) {
         throw new \Exception('Could not generate TCA files, error: ' . $e->getMessage() . $e->getFile());
     }
 }