/** * {@inheritdoc} * * @param FamilyInterface $object */ public function normalize($object, $format = null, array $context = []) { $normalizedRequirements = $this->normalizeRequirements($object); $transNormalized = $this->transNormalizer->normalize($object, $format, $context); $defaults = ['code' => $object->getCode()]; $normalizedData = ['attributes' => $this->normalizeAttributes($object), 'attribute_as_label' => $object->getAttributeAsLabel() ? $object->getAttributeAsLabel()->getCode() : '']; return array_merge($defaults, $transNormalized, $normalizedData, $normalizedRequirements); }
/** * {@inheritdoc} * * @param AttributeInterface $object */ public function normalize($object, $format = null, array $context = []) { $results = ['type' => $object->getAttributeType(), 'code' => $object->getCode()] + $this->transNormalizer->normalize($object, $format, $context); $results = array_merge($results, ['group' => $object->getGroup() ? $object->getGroup()->getCode() : null, 'unique' => (bool) $object->isUnique(), 'useable_as_grid_filter' => (bool) $object->isUseableAsGridFilter(), 'allowed_extensions' => implode(self::ITEM_SEPARATOR, $object->getAllowedExtensions()), 'metric_family' => $object->getMetricFamily(), 'default_metric_unit' => $object->getDefaultMetricUnit(), 'reference_data_name' => $object->getReferenceDataName(), 'available_locales' => $this->normalizeAvailableLocales($object), 'max_characters' => null === $object->getMaxCharacters() ? '' : (int) $object->getMaxCharacters(), 'validation_rule' => (string) $object->getValidationRule(), 'validation_regexp' => (string) $object->getValidationRegexp(), 'wysiwyg_enabled' => (bool) $object->isWysiwygEnabled(), 'number_min' => (string) $object->getNumberMin(), 'number_max' => (string) $object->getNumberMax(), 'decimals_allowed' => (bool) $object->isDecimalsAllowed(), 'negative_allowed' => (bool) $object->isNegativeAllowed(), 'date_min' => $this->normalizeDate($object->getDateMin()), 'date_max' => $this->normalizeDate($object->getDateMax()), 'max_file_size' => (string) $object->getMaxFileSize(), 'minimum_input_length' => null === $object->getMinimumInputLength() ? '' : (int) $object->getMinimumInputLength(), 'sort_order' => (int) $object->getSortOrder()]); if (isset($context['versioning'])) { $results = array_merge($results, $this->getVersionedData($object)); } else { $results = array_merge($results, ['localizable' => (bool) $object->isLocalizable(), 'scopable' => (bool) $object->isScopable()]); } return $results; }
/** * {@inheritdoc} * * @param GroupInterface $object */ public function normalize($object, $format = null, array $context = []) { $results = ['code' => $object->getCode(), 'type' => $object->getType()->getCode()]; $axisAttributes = $this->normalizeAxisAttributes($object); if (!empty($axisAttributes)) { $results += ['axis' => $axisAttributes]; } $results += $this->transNormalizer->normalize($object, $format, $context); if (isset($context['versioning']) && true === $context['versioning']) { $context['with_variant_group_values'] = true; } if (isset($context['with_variant_group_values']) && true === $context['with_variant_group_values']) { $results['values'] = $this->normalizeVariantGroupValues($object, $format, $context); } return $results; }
/** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { $data = ['code' => $object->getCode()] + $this->transNormalizer->normalize($object, $format, $context); return $data; }
/** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { return ['code' => $object->getCode(), 'parent' => $object->getParent() ? $object->getParent()->getCode() : ''] + $this->transNormalizer->normalize($object, $format, $context); }
/** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { $data = ['code' => $object->getCode()] + $this->transNormalizer->normalize($object, $format, $context); $data['attributeAsLabel'] = $object->getAttributeAsLabel() ? $object->getAttributeAsLabel()->getCode() : null; return $data; }