public function replaceEmptyValues(ValueSetInterface $valueSet)
    {
        // collect persisted attributevalues
        $persistedAttributes = array();
        foreach ($valueSet->getValues() as $value) {
            $persistedAttributes[] = $value->getAttribute();
        }

        $newValues = array();

        // Create empty entities for missing attributes
        $missingAttributes = array_diff($valueSet->getAttributes()->toArray(), $persistedAttributes);
        foreach ($missingAttributes as $attribute) {
            $provider = $this->providerPool->getValue($attribute->getValueType());
            $valueClass = $provider->getEntity();

            $value = new $valueClass();
            $valueSet->addValue($value);
            $value->setValueSet($valueSet);
            $value->setAttribute($attribute);

            $newValues[] = $value;
        }

        return $newValues;
    }
public function replaceEmptyValues(ValueSetInterface $valueSet)
    {
        // collect persisted attributevalues
        $persistedAttributes = array();
        foreach ($valueSet->getValues() as $value) {
            $persistedAttributes[] = $value->getAttribute();
        }

        $newValues = array();

        // Create empty entities for missing attributes
        $missingAttributes = array_diff($valueSet->getAttributes()->toArray(), $persistedAttributes);
        foreach ($missingAttributes as $attribute) {
            $provider = $this->providerPool->getValue($attribute->getValueType());
            $valueClass = $provider->getEntity();

            $value = new $valueClass();
            $valueSet->addValue($value);
            $value->setValueSet($valueSet);
            $value->setAttribute($attribute);

            $newValues[] = $value;
        }

        return $newValues;
    }
public function replaceEmptyValues ( ValueSetInterface $ valueSet ) { // collect persisted attributevalues $ persistedAttributes = array ( ) ; foreach ( $ valueSet -> getValues ( ) as $ value ) { $ persistedAttributes [ ] = $ value -> getAttribute ( ) ; } $ newValues = array ( ) ; // Create empty entities for missing attributes $ missingAttributes = array_diff ( $ valueSet -> getAttributes ( ) -> toArray ( ) , $ persistedAttributes ) ; foreach ( $ missingAttributes as $ attribute ) { $ provider = $ this -> providerPool -> getValue ( $ attribute -> getValueType ( ) ) ; $ valueClass = $ provider -> getEntity ( ) ; $ value = new $ valueClass ( ) ; $ valueSet -> addValue ( $ value ) ; $ value -> setValueSet ( $ valueSet ) ; $ value -> setAttribute ( $ attribute ) ; $ newValues [ ] = $ value ; } return $ newValues ; }
Creates empty entities for non-persisted attributes.

@param ValueSetInterface $valueSet

@return array
Creates empty entities for non - persisted attributes .