Esempio n. 1
0
 /**
  * @param string $sourceEntityClass
  * @param string $targetEntityClass
  * @param string $associationKind
  */
 public function createManyToOneAssociation($sourceEntityClass, $targetEntityClass, $associationKind)
 {
     $relationName = ExtendHelper::buildAssociationName($targetEntityClass, $associationKind);
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $targetEntityPrimaryKeyColumns = $this->getPrimaryKeyColumnNames($targetEntityClass);
     $targetFieldName = reset($targetEntityPrimaryKeyColumns);
     // add relation to owning entity
     $this->relationBuilder->addManyToOneRelation($extendConfigProvider->getConfig($sourceEntityClass), $targetEntityClass, $relationName, $targetFieldName);
     // update attributes for new association
     $fieldConfig = $extendConfigProvider->getConfig($sourceEntityClass, $relationName);
     if ($fieldConfig->is('state', ExtendScope::STATE_NEW)) {
         $targetEntityConfig = $this->configManager->getProvider('entity')->getConfig($targetEntityClass);
         $this->relationBuilder->updateFieldConfigs($sourceEntityClass, $relationName, ['entity' => ['label' => $this->getAssociationLabel('label', $sourceEntityClass, $relationName, $targetEntityConfig), 'description' => $this->getAssociationLabel('description', $sourceEntityClass, $relationName, $targetEntityConfig)], 'view' => ['is_displayable' => false], 'form' => ['is_enabled' => false]]);
     }
 }
 /**
  * @param string    $enumValueClassName The full class name of an entity is used to store enum values
  * @param string    $enumCode           The unique identifier of an enum
  * @param bool      $isMultiple         Indicates whether several options can be selected for this enum
  *                                      or it supports only one selected option
  * @param bool|null $isPublic           Indicates whether this enum can be used by any entity or
  *                                      it is designed to use in one entity only
  *                                      NULL means unspecified. In this case this attribute will not be
  *                                      changed for existing enum entity and will be set to FALSE
  *                                      for new enum entity
  */
 protected function createEnumValueConfigEntityModel($enumValueClassName, $enumCode, $isMultiple, $isPublic)
 {
     if ($this->configManager->hasConfigEntityModel($enumValueClassName)) {
         if (null !== $isPublic) {
             $this->relationBuilder->updateEntityConfigs($enumValueClassName, ['enum' => ['public' => $isPublic]]);
         }
         return;
     }
     if (null === $isPublic) {
         $isPublic = false;
     }
     // create entity
     $this->configManager->createConfigEntityModel($enumValueClassName, ConfigModelManager::MODE_HIDDEN);
     $this->relationBuilder->updateEntityConfigs($enumValueClassName, ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode), 'plural_label' => ExtendHelper::getEnumTranslationKey('plural_label', $enumCode), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode)], 'extend' => ['owner' => ExtendScope::OWNER_SYSTEM, 'is_extend' => true, 'table' => $this->nameGenerator->generateEnumTableName($enumCode, true), 'inherit' => ExtendHelper::BASE_ENUM_VALUE_CLASS], 'enum' => ['code' => $enumCode, 'public' => $isPublic, 'multiple' => $isMultiple]]);
     // create fields
     $this->configManager->createConfigFieldModel($enumValueClassName, 'id', 'string');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'id', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'id'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'id')], 'importexport' => ['identity' => true]]);
     $this->configManager->createConfigFieldModel($enumValueClassName, 'name', 'string');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'name', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'name'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'name')], 'datagrid' => ['is_visible' => false]]);
     $this->configManager->createConfigFieldModel($enumValueClassName, 'priority', 'integer');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'priority', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'priority'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'priority')], 'datagrid' => ['is_visible' => false]]);
     $this->configManager->createConfigFieldModel($enumValueClassName, 'default', 'boolean');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'default', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'default'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'default')], 'datagrid' => ['is_visible' => false]]);
 }