/** * @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]]); }
public function testHasConfigEntityModel() { $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->willReturn($this->createEntityConfigModel(self::ENTITY_CLASS)); $result = $this->configManager->hasConfigEntityModel(self::ENTITY_CLASS); $this->assertTrue($result); }
/** * @param $value * * @return bool */ protected function hasConfigForInheritanceTarget($value) { $result = is_array($value) && array_key_exists('target', $value) && $this->configManager->hasConfigEntityModel($value['target']); return $result; }