@param $values
@param $modelId
@param $propertyId
@param $valueField
@param int $langId

@return array
491572
private static function prepareRows($values, $modelId, $propertyId, $valueField, $langId = 0)
    {
        if (true === empty($values)) {
            return [];
        }
        $rows = [];
        foreach ((array) $values as $index => $value) {
            if ($value !== 0 && true === empty($value)) {
                continue;
            }
            $rows[] = [
                $modelId,
                $propertyId,
                $index,
                $valueField === 'value_integer' ? (int) $value : null,
                $valueField === 'value_float' ? (float) $value : null,
                $valueField === 'value_string' ? $value : '',
                $valueField === 'value_text' ? $value : '',
                $langId,
            ];
        }
        return $rows;
    }
984396
protected function processValues($manager, $xpath, $operator, $values)
    {
        /** @var $node DOMNode */
        foreach ($values as $node) {
            $value = new OperatorValue();
            $value->setValue($node->getAttribute('value'));

            $translations = $xpath->query('translations/translation', $node);
            /** @var $trans DOMNode */
            foreach ($translations as $trans) {
                $translation = new OperatorValueTranslation();
                $translation->setLocale($trans->getAttribute('locale'));
                $translation->setName($trans->nodeValue);

                $translation->setOperatorValue($value);
                $value->addTranslation($translation);
                $manager->persist($translation);
            }

            $value->setOperator($operator);
            $operator->addValue($value);
            $manager->persist($value);
        }
    }
79897
public function relatedByLanguageValues($values, $attribute = null)
    {
        return $this->anyLanguageValues($values, $attribute)->addOrderBy(new Expression('COUNT(*) DESC'));
    }
957643
protected function processLanguageTaggedPropertyValue($propertyValue)
    {
        $language = null;
        if (is_object($propertyValue)) {
            // If this is an invalid language tagged object
            if (!isset($propertyValue->lang) || !isset($propertyValue->value)) {
                throw new RuntimeException(
                    RuntimeException::INVALID_LANGUAGE_TAGGED_VALUE_STR,
                    RuntimeException::INVALID_LANGUAGE_TAGGED_VALUE
                );
            }

            $language      = $propertyValue->lang;
            $propertyValue = $propertyValue->value;
        }

        return [$propertyValue, $language];
    }
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))));
    }
700230
public function setFieldsPropertyValues($property,$values){
		$i=0;
		if(\is_array($values)===false){
			$values=\array_fill(0, $this->count(),$values);
		}
		foreach ($values as $value){
			$c=$this->content[$i++];
			if(isset($c)){
				$df=$c->getDataField();
				$df->setProperty($property,$value);
			}
			else{
				return $this;
			}
		}
		return $this;
	}
134361
public function serializeValueBag(ValueBagInterface $valueBag)
    {
        $return = [];

        foreach ($valueBag->getValues() as $value) {

            $serialized = array(
                'value' => $value->getValue()
            );

            $filters = $this->serializeFilterGroups($value->getFilter()->getFilterGroups());
            if(!empty($filters)) {
                $serialized['filters'] = $filters;
            }

            if($value->isFeature()) {
                $serialized['is_feature'] = true;
            }

            $return[] =  $serialized;
        }

        return $return;
    }
1214381
protected function getValues(array $values)
    {
        $array = [];

        $versionedKeys = array_merge(
            $this->model->getVersionedAttributeNames(),
            [$this->model->getLatestVersionColumn(), $this->model->getVersionColumn(), $this->model->getVersionKeyName()]
        );

        foreach ($values as $key => $value) {
            if (! $this->isVersionedKey($key, $versionedKeys)) {
                $array[$key] = $value;
            }
        }

        return $array;
    }
398813
private function prepareValues($values, callable $valueCallable = null)
    {
        if (is_array($values)) {
            foreach ($values as &$value) {
                if ($valueCallable) {
                    $value = call_user_func_array($valueCallable, [(string) $value]);
                }

                $value = (string) $value;
            }
            unset($value);

            $values = array_values($values);
        } else {
            if ($valueCallable) {
                $values = call_user_func_array($valueCallable, [(string) $values]);
            }

            $values = (string) $values;
        }

        return $values;
    }
897550
protected function normalizeValues(array $values, string $property): ?array
    {
        foreach ($values as $key => $value) {
            if (!\is_int($key) || !\is_string($value)) {
                unset($values[$key]);
            }
        }

        if (empty($values)) {
            $this->getLogger()->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('At least one value is required, multiple values should be in "%1$s[]=firstvalue&%1$s[]=secondvalue" format', $property)),
            ]);

            return null;
        }

        return array_values($values);
    }
1034490
public static function exportModels($modelIds) {
        $dbWrapper = core_kernel_classes_DbWrapper::singleton();
        $result = $dbWrapper->query('SELECT DISTINCT "subject", "predicate", "object", "l_language" FROM "statements" 
            WHERE "modelid" IN (\''.implode('\',\'', $modelIds).'\')');
        	
        common_Logger::i('Found '.$result->rowCount().' entries for models '.implode(',', $modelIds));
        return self::statement2rdf($result);
    }
1367520
protected function loadEntityValues($valueClass, array $entitiesById)
    {
        foreach ($this->getValues($valueClass, $entitiesById) as $valueEntity) {
            $data = $valueEntity->getData();

            $refl = new \ReflectionClass($data);
            $valuesProperty = $refl->getProperty('values');
            $valuesProperty->setAccessible(true);
            $dataValues = $valuesProperty->getValue($data);
            if ($dataValues instanceof PersistentCollection) {
                $dataValues->setInitialized(true);
                $dataValues->add($valueEntity);
            } else {
                throw new \UnexpectedValueException('Data.values is not an instance of PersistentCollection');
            }
        }
    }
1073947
private function convertValuesToIds($varValue): array
    {
        $aliasColumn = $this->getAliasColumn();
        $alias       = [];
        foreach ($varValue as $valueId => $value) {
            if (array_key_exists($aliasColumn, $value)) {
                $alias[$valueId] = $value[$aliasColumn];
                continue;
            }
            if (array_key_exists(self::TAGS_RAW, $value) && array_key_exists($aliasColumn, $value[self::TAGS_RAW])) {
                $alias[$valueId] = $value[self::TAGS_RAW][$aliasColumn];
            }
        }

        return $alias;
    }
1173358
protected function getValuesById($valueIds, $attrOnly = [])
    {
        $recursionKey = $this->getMetaModel()->getTableName();

        // Prevent recursion.
        static $tables = [];
        if (isset($tables[$recursionKey])) {
            return [];
        }
        $tables[$recursionKey] = $recursionKey;

        $metaModel = $this->getSelectMetaModel();
        $filter    = $metaModel->getEmptyFilter()->addFilterRule(new StaticIdList($valueIds));
        $items     = $metaModel->findByFilter($filter, 'id', 0, 0, 'ASC', $attrOnly);
        unset($tables[$recursionKey]);

        return $this->itemsToValues($items);
    }
1281229
public static function execute($values, ContextInterface $context): array
    {
        // let's consider an empty index list as `exists`
        $result = is_array($values);

        if ($result === true && empty($values) === false) {
            $tableName   = $context->getProperties()->getProperty(static::PROPERTY_TABLE_NAME);
            $primaryName = $context->getProperties()->getProperty(static::PROPERTY_PRIMARY_NAME);

            /** @var Connection $connection */
            $connection   = $context->getContainer()->get(Connection::class);
            $builder      = $connection->createQueryBuilder();
            $placeholders = [];
            foreach ($values as $value) {
                $placeholders[] = $builder->createPositionalParameter($value);
            }
            $statement = $builder
                ->select('count(*)')
                ->from($tableName)
                ->where($builder->expr()->in($primaryName, $placeholders))
                ->execute();

            $count  = (int)$statement->fetchColumn();
            $result = $count === count($values);
        }

        $reply = $result === true ?
            static::createSuccessReply($values) :
            static::createErrorReply(
                $context,
                $values,
                ErrorCodes::EXIST_IN_DATABASE_MULTIPLE,
                Messages::EXIST_IN_DATABASE_MULTIPLE,
                []
            );

        return $reply;
    }
1342727
public function values(array $values)
    {
        $this->fieldValues = array();

        $this->fieldsSql   = '?i';
        $this->fieldValues[] = array_keys($values);

        $this->valuesSql   = array();

        foreach ($values as $v) {
            if (is_object($v) and $v instanceof SqlValueInterface) {
                $this->valuesSql[] = $v->getSql();
                $this->fieldValues = array_merge($this->fieldValues, $v->getValues());
            } else {
                $this->valuesSql[]   = '?q';
                $this->fieldValues[] = $v;
            }
        }

        $this->valuesSql = implode(', ', $this->valuesSql);

        return $this;
    }
188581
public function manyToPHP(array $values, array $fields, Driver $driver)
    {
        foreach ($fields as $field) {
            if (!isset($values[$field])) {
                continue;
            }

            $values[$field] = Locale::parse($values[$field]);
        }

        return $values;
    }