public function getForeignKeyName()
 {
     if (empty($this->foreignKeyName)) {
         $foreignKeyName = strtolower($this->getDomainObject()->getName());
         if (\EBT\ExtensionBuilder\Service\ValidationService::isReservedMYSQLWord($foreignKeyName)) {
             $foreignKeyName = 'tx_' . $foreignKeyName;
         }
         return $foreignKeyName;
     } else {
         return $this->foreignKeyName;
     }
 }
 /**
  * Returns a field name used in the database. This is the property name converted
  * to lowercase underscore (mySpecialProperty -> my_special_property).
  *
  * @return string the field name in lowercase underscore
  */
 public function getFieldName()
 {
     $fieldName = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->name);
     if (\EBT\ExtensionBuilder\Service\ValidationService::isReservedMYSQLWord($fieldName)) {
         $fieldName = $this->domainObject->getExtension()->getShortExtensionKey() . '_' . $fieldName;
     }
     return $fieldName;
 }
 /**
  *
  * @param array $relationJsonConfiguration
  * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject
  * @throws \Exception
  * @return \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\AbstractRelation
  */
 public function buildRelation($relationJsonConfiguration, $domainObject)
 {
     $relationSchemaClassName = 'EBT\\ExtensionBuilder\\Domain\\Model\\DomainObject\\Relation\\';
     $relationSchemaClassName .= ucfirst($relationJsonConfiguration['relationType']) . 'Relation';
     if (!class_exists($relationSchemaClassName)) {
         throw new \Exception('Relation of type ' . $relationSchemaClassName . ' not found (configured in "' . $relationJsonConfiguration['relationName'] . '")');
     }
     /**
      * @var $relation \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\AbstractRelation
      */
     $relation = new $relationSchemaClassName();
     $relation->setName($relationJsonConfiguration['relationName']);
     $relation->setLazyLoading((bool) $relationJsonConfiguration['lazyLoading']);
     $relation->setExcludeField($relationJsonConfiguration['propertyIsExcludeField']);
     $relation->setDescription($relationJsonConfiguration['relationDescription']);
     $relation->setUniqueIdentifier($relationJsonConfiguration['uid']);
     $relation->setType($relationJsonConfiguration['type']);
     if (!empty($relationJsonConfiguration['foreignRelationClass'])) {
         // relations without wires
         if (strpos($relationJsonConfiguration['foreignRelationClass'], '\\') > 0) {
             // add trailing slash if not set
             $relationJsonConfiguration['foreignRelationClass'] = '\\' . $relationJsonConfiguration['foreignRelationClass'];
         }
         $relation->setForeignClassName($relationJsonConfiguration['foreignRelationClass']);
         $relation->setRelatedToExternalModel(TRUE);
         $extbaseClassConfiguration = $this->configurationManager->getExtbaseClassConfiguration($relationJsonConfiguration['foreignRelationClass']);
         if (isset($extbaseClassConfiguration['tableName'])) {
             $foreignDatabaseTableName = $extbaseClassConfiguration['tableName'];
             $this->relatedForeignTables[$foreignDatabaseTableName] = 1;
         } else {
             $foreignDatabaseTableName = Tools::parseTableNameFromClassName($relationJsonConfiguration['foreignRelationClass']);
         }
         $relation->setForeignDatabaseTableName($foreignDatabaseTableName);
         if ($relation instanceof \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\ZeroToManyRelation) {
             $foreignKeyName = strtolower($domainObject->getName());
             if (\EBT\ExtensionBuilder\Service\ValidationService::isReservedMYSQLWord($foreignKeyName)) {
                 $foreignKeyName = 'tx_' . $foreignKeyName;
             }
             if (isset($this->relatedForeignTables[$foreignDatabaseTableName])) {
                 $foreignKeyName .= $this->relatedForeignTables[$foreignDatabaseTableName];
                 $this->relatedForeignTables[$foreignDatabaseTableName] += 1;
             } else {
                 $foreignDatabaseTableName = Tools::parseTableNameFromClassName($relationJsonConfiguration['foreignRelationClass']);
             }
             $relation->setForeignDatabaseTableName($foreignDatabaseTableName);
         }
         if ($relation->isFileReference() && !empty($relationJsonConfiguration['maxItems'])) {
             /** @var $relation \EBT\ExtensionBuilder\Domain\Model\DomainObject\FileProperty */
             $relation->setMaxItems($relationJsonConfiguration['maxItems']);
         }
     }
     return $relation;
 }
 /**
  *
  * @param string $word
  *
  * @return bool
  */
 public static function isReservedWord($word)
 {
     if (\EBT\ExtensionBuilder\Service\ValidationService::isReservedMYSQLWord($word) || \EBT\ExtensionBuilder\Service\ValidationService::isReservedTYPO3Word($word)) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  *
  * @param string $word
  *
  * @return bool
  */
 public static function isReservedWord($word)
 {
     return ValidationService::isReservedMYSQLWord($word) || ValidationService::isReservedTYPO3Word($word);
 }