/** * {@inheritdoc} */ public function getData() { $types = $this->fieldTypeProvider->getSupportedFieldTypes(); $objects = []; foreach ($types as $type) { $entity = new FieldConfigModel(); $this->fillEntityData($type, $entity); $objects[] = $entity; } return new \ArrayIterator($objects); }
/** * {@inheritdoc} */ protected function getBackendHeader() { $header = ['fieldName', 'is_serialized', 'type']; foreach ($this->fieldTypeProvider->getSupportedFieldTypes() as $fieldType) { $properties = $this->fieldTypeProvider->getFieldProperties($fieldType); foreach ($properties as $scope => $fields) { foreach ($fields as $code => $config) { $field = sprintf('%s.%s', $scope, $code); if (in_array($field, $this->excludedFields, true) || in_array($field, $header, true)) { continue; } $header[] = $field; } } } return array_merge($header, ['enum.enum_options.0.label', 'enum.enum_options.0.is_default', 'enum.enum_options.1.label', 'enum.enum_options.1.is_default', 'enum.enum_options.2.label', 'enum.enum_options.2.is_default']); }
/** * @param array $reverseRelationTypes * * @return array */ protected function getFieldTypeChoices($reverseRelationTypes) { $fieldTypes = $relationTypes = []; foreach ($this->fieldTypeProvider->getSupportedFieldTypes() as $type) { $fieldTypes[$type] = $this->translator->trans(self::TYPE_LABEL_PREFIX . $type); } foreach ($this->fieldTypeProvider->getSupportedRelationTypes() as $type) { $relationTypes[$type] = $this->translator->trans(self::TYPE_LABEL_PREFIX . $type); } uasort($fieldTypes, 'strcasecmp'); uasort($relationTypes, 'strcasecmp'); if (!empty($reverseRelationTypes)) { uasort($reverseRelationTypes, 'strcasecmp'); $relationTypes = array_merge($relationTypes, $reverseRelationTypes); } $result = [$this->translator->trans(self::GROUP_TYPE_PREFIX . self::GROUP_FIELDS) => $fieldTypes, $this->translator->trans(self::GROUP_TYPE_PREFIX . self::GROUP_RELATIONS) => $relationTypes]; return $result; }
/** * @param FieldConfigModel $entity * @return null|FieldConfigModel */ protected function processEntity(FieldConfigModel $entity) { $supportedTypes = $this->fieldTypeProvider->getSupportedFieldTypes(); if ((string) $entity->getFieldName() === '') { $this->addErrors($this->translator->trans('oro.entity_config.import.message.invalid_field_name')); return null; } if (!in_array($entity->getType(), $supportedTypes, true)) { $this->addErrors($this->translator->trans('oro.entity_config.import.message.invalid_field_type')); return null; } $existingEntity = $this->findExistingEntity($entity); $this->isExistingEntity = (bool) $existingEntity; if ($this->isExistingEntity) { if ($entity->getType() !== $existingEntity->getType()) { $this->addErrors($this->translator->trans('oro.entity_config.import.message.change_type_not_allowed')); return null; } if ($this->isSystemField($existingEntity)) { return null; } } return $entity; }
public function testGetSupportedFieldTypes() { $types = ['string', 'boolean', 'date', 'file']; $provider = new FieldTypeProvider($this->configManager, $types, []); $this->assertEquals($types, $provider->getSupportedFieldTypes()); }