src/Attribute/TranslatedReference.php
public function setTranslatedDataFor($arrValues, $strLangCode)
    {
        // First off determine those to be updated and those to be inserted.
        $arrIds      = array_keys($arrValues);
        $arrExisting = $this->fetchExistingIdsFor($arrIds, $strLangCode);
        $arrNewIds   = array_diff($arrIds, $arrExisting);

        // Update existing values - delete if empty.
        foreach ($arrExisting as $intId) {
            $queryBuilder = $this->connection->createQueryBuilder();
            $this->buildWhere($queryBuilder, $intId, $strLangCode);

            if ($arrValues[$intId]['value'] != '') {
                $queryBuilder->update($this->getValueTable());

                foreach ($this->getSetValues($arrValues[$intId], $intId, $strLangCode) as $name => $value) {
                    $queryBuilder
                        ->set($name, ':' . $name)
                        ->setParameter($name, $value);
                }
            } else {
                $queryBuilder->delete($this->getValueTable());
            }

            $queryBuilder->execute();
        }

        // Insert the new values.
        foreach ($arrNewIds as $intId) {
            if ($arrValues[$intId]['value'] == '') {
                continue;
            }

            $this->connection->insert(
                $this->getValueTable(),
                $this->getSetValues($arrValues[$intId], $intId, $strLangCode)
            );
        }
    }
public function setTranslatedDataFor($arrValues, $strLangCode)
    {
        // First off determine those to be updated and those to be inserted.
        $arrIds      = array_keys($arrValues);
        $arrExisting = $this->fetchExistingIdsFor($arrIds, $strLangCode);
        $arrNewIds   = array_diff($arrIds, $arrExisting);

        // Update existing values - delete if empty.
        foreach ($arrExisting as $intId) {
            $queryBuilder = $this->connection->createQueryBuilder();
            $this->buildWhere($queryBuilder, $intId, $strLangCode);

            if ($arrValues[$intId]['value'] != '') {
                $queryBuilder->update($this->getValueTable());

                foreach ($this->getSetValues($arrValues[$intId], $intId, $strLangCode) as $name => $value) {
                    $queryBuilder
                        ->set($name, ':' . $name)
                        ->setParameter($name, $value);
                }
            } else {
                $queryBuilder->delete($this->getValueTable());
            }

            $queryBuilder->execute();
        }

        // Insert the new values.
        foreach ($arrNewIds as $intId) {
            if ($arrValues[$intId]['value'] == '') {
                continue;
            }

            $this->connection->insert(
                $this->getValueTable(),
                $this->getSetValues($arrValues[$intId], $intId, $strLangCode)
            );
        }
    }
{@inheritDoc}