Get the values data of multiple values for a given attribute

@param AttributeInterface $attribute
@param array|null         $context

@throws InvalidValueDataException
@throws MissingAttributeException
@throws ContextException

@return ArrayCollection
515822
public function getValuesData(AttributeInterface $attribute, array $context = null)
    {
        $this->checkAttribute($attribute);
        $valuesData = new ArrayCollection();
        try {
            foreach ($this->getValues($attribute, $context) as $value) {
                $valuesData->add($value->getValueData());
            }
        } catch (ExceptionInterface $e) {
            throw new InvalidValueDataException("Unable to access data for attribute {$attribute->getCode()}", 0, $e);
        }


        return $valuesData;
    }
328525
protected function updateData(array $data, $attribute, $attributeValue)
    {
        if ($this->nameConverter) {
            $attribute = $this->nameConverter->normalize($attribute);
        }

        $data[$attribute] = $attributeValue;

        return $data;
    }
521928
protected function getConvertedValues($values, $attribute, $direction, AttributeConverterInterface $aggregate = null)
    {
        $values = is_array($values) ? $values : [$values];
        $converter = $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);

        if (!$aggregate && $converter->getShouldAggregateValues() && $direction == 'toLdap') {
            $values = $this->convertAggregateValues($attribute, $values);
        } else {
            $values = $this->doConvertValues($attribute, $values, $direction, $aggregate);
        }

        return $values;
    }
49871
protected function getValuesByAttribute(AttributeInterface $attribute)
    {
        if (null === $this->valuesByAttributes) {
            $this->valuesByAttributes = [];
        }

        if (!array_key_exists($attribute->getCode(), $this->valuesByAttributes)) {
            $this->valuesByAttributes[$attribute->getCode()] = [];
            foreach ($this->values as $value) {
                if ($value->getAttributeCode() === $attribute->getCode()) {
                    $this->addValueByAttribute($value);
                }
            }
        }

        return $this->valuesByAttributes[$attribute->getCode()];
    }
473538
public function allLanguageValues($values, $attribute = null)
    {
        $model = new $this->owner->modelClass();

        return $this->anyLanguageValues($values, $attribute)->andHaving(new Expression('COUNT(*) = ' . count($model->filterLanguageValues($values))));
    }
692630
protected function denormalizeCollection(string $attribute, PropertyMetadata $propertyMetadata, Type $type, string $className, $value, ?string $format, array $context): array
    {
        if (!\is_array($value)) {
            throw new InvalidArgumentException(sprintf(
                'The type of the "%s" attribute must be "array", "%s" given.', $attribute, \gettype($value)
            ));
        }

        $collectionKeyType = $type->getCollectionKeyType();
        $collectionKeyBuiltinType = null === $collectionKeyType ? null : $collectionKeyType->getBuiltinType();

        $values = [];
        foreach ($value as $index => $obj) {
            if (null !== $collectionKeyBuiltinType && !\call_user_func('is_'.$collectionKeyBuiltinType, $index)) {
                throw new InvalidArgumentException(sprintf(
                        'The type of the key "%s" must be "%s", "%s" given.',
                        $index, $collectionKeyBuiltinType, \gettype($index))
                );
            }

            $values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $this->createChildContext($context, $attribute));
        }

        return $values;
    }
482730
protected function getAttributeContext(
        DataInterface $object,
        $attribute,
        /** @noinspection PhpUnusedParameterInspection */
        $rawValue,
        array $context
    ) {
        return array_merge(
            $context,
            [
                'parent' => $object,
                'attribute' => $attribute,
            ]
        );
    }
556741
protected function getCurrentLdapAttributeValue($attribute)
    {
        if (!$this->getDn() || !$this->getLdapConnection()) {
            throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
        }

        $query = new LdapQueryBuilder($this->getLdapConnection());
        try {
            return $query->select($attribute)
                ->where($query->filter()->present('objectClass'))
                ->setBaseDn($this->getDn())
                ->setScopeBase()
                ->getLdapQuery()
                ->getSingleScalarOrNullResult();
        } catch (EmptyResultException $e) {
            throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
        }
    }
356228
public function getAttribute(string $attribute): array
    {
        // Determine if the attribute is present
        if (! array_key_exists($attribute, $this->attributes)) {
            return [];
        }

        // Return the value of the attribute
        return $this->attributes[$attribute];
    }
244471
protected function createComplexValue(AttributeInterface $attribute, array $options = array())
    {
        $values = array();
        $value_holder = $attribute->createValueHolder();
        $value_type = $value_holder->getValueType();

        if (class_exists($value_type)
            && preg_grep('#ComplexValueInterface$#', class_implements($value_type))
        ) {
            foreach ($value_type::getPropertyMap() as $property_name => $property_type) {
                switch ($property_type) {
                    case ComplexValue::VALUE_TYPE_TEXT:
                        if ($this->shouldGuessByName($options)) {
                            $values[$property_name] = TextGuesser::guess($property_name, $this->faker);
                        }
                        if (empty($values[$property_name])) {
                            $values[$property_name] = $this->faker->words(3, true);
                        }
                        break;
                    case ComplexValue::VALUE_TYPE_URL:
                        $values[$property_name] = $this->faker->url;
                        break;
                    case ComplexValue::VALUE_TYPE_BOOLEAN:
                        $values[$property_name] = $this->faker->boolean();
                        break;
                    case ComplexValue::VALUE_TYPE_INTEGER:
                        $values[$property_name] = $this->faker->numberBetween(0, 10);
                        break;
                    case ComplexValue::VALUE_TYPE_FLOAT:
                        $values[$property_name] = $this->faker->randomFloat(5);
                        break;
                    case ComplexValue::VALUE_TYPE_ARRAY:
                        $numberOfEntries = $this->faker->numberBetween(0, 3);
                        for ($i = 0; $i < $numberOfEntries; $i++) {
                            $values[$property_name][$this->faker->word] = $this->faker->word;
                        }
                        break;
                    default:
                        throw new BadValueException(sprintf(
                            'Unexpected ComplexValue property type "%s" on %s',
                            $property_type,
                            $value_type
                        ));
                }
            }
        }

        return new $value_type($values);
    }
84162
protected function parseArray(AttributeInterface $attribute, $dataValues)
    {
        $m = 'AbstractData::parseArray is deprecated and will be removed in a future version, ';
        $m .= 'use ensureNativeArray instead';
        @trigger_error($m, E_USER_DEPRECATED);

        return $this->ensureNativeArray($dataValues, $this->getFamilyCode().'.'.$attribute->getCode());
    }
166328
public function getAvailableOptions(
        ProductInterface $product,
        AttributeInterface $attribute
    ) {
        $availableOptions = new ArrayCollection();

        foreach ($product->getVariants() as $variant) {

            /**
             * @var VariantInterface $variant
             */
            if (!$variant->isEnabled() || $variant->getStock() <= 0) {
                continue;
            }

            foreach ($variant->getOptions() as $option) {
                /**
                 * @var ValueInterface $option
                 */
                if ($option->getAttribute() == $attribute &&
                    !$availableOptions->contains($option)
                ) {
                    $availableOptions->add($option);
                }
            }
        }

        return $availableOptions;
    }
1186298
public function getSetterCodeDocumentationParameterLines(JavaAttribute $attribute)
    {
        $lines = [];

        $lines[] = '@param ' . $attribute->getType() . ' ' . $attribute->getLowerFullName();

        return $lines;
    }
1299162
public function allCategoryValues($values, $attribute = null)
    {
        $model = new $this->owner->modelClass();

        return $this->anyCategoryValues($values, $attribute)->andHaving(new Expression('COUNT(*) = ' . count($model->filterCategoryValues($values))));
    }
574292
private function canIndexAttribute(AttributeInterface $attribute)
    {
        // 'price' attribute is declared as nested field into the indices file.
        $canIndex = $attribute->getBackendType() != 'static' && $attribute->getAttributeCode() !== 'price';

        if ($canIndex && $attribute->getBackendModel()) {
            foreach ($this->indexedBackendModels as $indexedBackendModel) {
                $canIndex = is_a($attribute->getBackendModel(), $indexedBackendModel, true);
                if ($canIndex) {
                    return $canIndex;
                }
            }
        }

        return $canIndex;
    }
103929
public function getAttributeChangeset(AttributeInterface $attribute)
    {
        if (!array_key_exists($attribute->getCode(), $this->getValuesChangeset())) {
            return [];
        }

        return $this->getValuesChangeset()[$attribute->getCode()];
    }
1269655
public function getAttribute($attribute)
    {
        //Check this attribute is support
        if (isset($this->input_map[$attribute])) {
            return $this->input_map[$attribute];
        } else {
            throw new AttributeInvalidException('Attribute not supported by this library');
        }
    }