Creates empty entities for non-persisted attributes.

@param ValueSetInterface $valueSet

@return array
423712
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;
    }
1088698
public function setTemplateValues(EntityInterface $templateValues = null)
    {
        if (!$templateValues instanceof TemplateValues) {
            $templateValues = new TemplateValues($templateValues);
        }
        $this->templateValues = $templateValues;
        return $this;
    }
874729
private function flattenKeySet(KeySet $keySet)
    {
        $keys = $keySet->keySetObject();

        if (!empty($keys['ranges'])) {
            foreach ($keys['ranges'] as $index => $range) {
                foreach ($range as $type => $rangeKeys) {
                    $range[$type] = $this->mapper->encodeValuesAsSimpleType($rangeKeys);
                }

                $keys['ranges'][$index] = $range;
            }
        }

        if (!empty($keys['keys'])) {
            $keys['keys'] = $this->mapper->encodeValuesAsSimpleType($keys['keys'], true);
        }

        return $this->arrayFilterRemoveNull($keys);
    }
638462
private function parseFacetsIntoObjects(SearchResultSet $resultSet)
    {
        // Make sure we can access the facet configuration
        if (!$resultSet->getUsedSearchRequest() || !$resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()) {
            return $resultSet;
        }

        // Read the response
        $response = $resultSet->getResponse();
        if (!is_object($response->facet_counts) && !is_object($response->facets)) {
            return $resultSet;
        }

        /** @var FacetRegistry $facetRegistry */
        $facetRegistry = $this->getFacetRegistry();
        $facetsConfiguration = $resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()->getSearchFacetingFacets();

        foreach ($facetsConfiguration as $name => $options) {
            if (!is_array($options)) {
                continue;
            }
            $facetName = rtrim($name, '.');
            $type = !empty($options['type']) ? $options['type'] : '';

            $parser = $facetRegistry->getPackage($type)->getParser();
            $facet = $parser->parse($resultSet, $facetName, $options);
            if ($facet !== null) {
                $resultSet->addFacet($facet);
            }
        }

        $this->applyRequirements($resultSet);

        return $resultSet;
    }
36794
public static function fromAttributeValues(AttributeValue ...$values): self
    {
        // we need at least one value to determine OID
        if (!count($values)) {
            throw new \LogicException("No values.");
        }
        $oid = reset($values)->oid();
        return new self(new AttributeType($oid), ...$values);
    }
221510
public static function getDimensionsInContext( $variableSet, $context )
	{
		$result = array();

		if ( isset( $context['segment'] ) )
		{
			$result = array_merge( $result, FactValues::processSegmentForExplicitDimensions( $variableSet, $context['segment'] ) );
			$result = array_merge( $result, FactValues::processSegmentForTypedDimensions( $variableSet, $context['segment'] ) );
		}

		if ( isset( $context['scenario'] ) )
		{
			$result = array_merge( $result, FactValues::processSegmentForExplicitDimensions( $variableSet, $context['scenario'] ) );
			$result = array_merge( $result, FactValues::processSegmentForTypedDimensions( $variableSet, $context['scenario'] ) );
		}

		$entity = $context['entity'];

		if ( isset( $entity['segment'] ) )
		{
			$result = array_merge( $result, FactValues::processSegmentForExplicitDimensions( $variableSet, $entity['segment'] ) );
			$result = array_merge( $result, FactValues::processSegmentForTypedDimensions( $variableSet, $entity['segment'] ) );
		}

		if ( isset( $entity['scenario'] ) )
		{
			$result = array_merge( $result, FactValues::processSegmentForExplicitDimensions( $variableSet, $entity['scenario'] ) );
			$result = array_merge( $result, FactValues::processSegmentForTypedDimensions( $variableSet, $entity['scenario'] ) );
		}

		return $result;
	}
96895
protected static function mapToDatabase($type, $valueName) {
    $mapper = self::getMapper($type);
    if ($mapper->hasAttribute($valueName)) {
      $attributeDescription = $mapper->getAttribute($valueName);
    }
    else {
      // if the attribute does not exist, it might be the column name already
      foreach ($mapper->getAttributes() as $curAttributeDesc) {
        if ($curAttributeDesc->getColumn() == $valueName) {
          $attributeDescription = $curAttributeDesc;
          break;
        }
      }
    }
    if (!$attributeDescription) {
      throw new PersistenceException("No attribute '".$valueName."' exists in '".$type."'");
    }

    $table = $mapper->getRealTableName();
    $column = $attributeDescription->getColumn();
    return [$table, $column];
  }
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;
    }
657937
public function createEmpty()
    {
        $entity = new Entity($this->definition);
        $fields = $this->definition->getEditableFieldNames();
        foreach ($fields as $field) {
            $value = null;
            if ($this->definition->getType($field) == 'fixed') {
                $value = $this->definition->getField($field, 'value');
            }
            $entity->set($field, $value);
        }
        $entity->set('id', null);
        return $entity;
    }
581801
protected function prepareAttributes($attributes)
    {
        foreach($this->getAttributeConfig() as $attr => $config){

            // If the attribute is not defined in model or $attributes array
            // set the default value.
            if(!isset($this->attributes[$attr]) && !isset($attributes[$attr])){

                $attributes[$attr] = $config['default'];

            }

        }

        foreach($attributes as $key => $value){

            if(isset($this->config['attributes'][$key])){

                $attributes[$key] = $this->$key()->before_save($value);

            } elseif(isset($this->config['relationships'][$key])){

                unset($attributes[$key]);

                $relationship = $this->config['relationships'][$key];

                $this->translateShorthand($value);

                switch($relationship['type']){

                    case Relationship::HAS_PIVOT:

                        if($value instanceof Collection) $value = $value->all();

                        if($value instanceof EntityContract) $value = [$value];

                        $this->$key()->saveMany($value);

                        break;

                    case Relationship::HAS_MANY:

                        $this->$key()->saveMany((array)$value);

                        break;

                    case Relationship::BELONGS_TO:

                        $this->$key()->associate($value);

                        break;

                    case Relationship::HAS_ONE:

                        $this->$key()->save($value);

                        break;

                    default:

                        throw new \Exception(sprintf(
                            "Unknown relationship type \"%s\" on entity \"%s\"",
                            $relationship['type'],
                            $relationship['entity']
                        ));

                        break;
                }

            }

        }

        return $attributes;
    }
638484
protected function getParsedSearchResults($resultSet)
    {
        /** @var ResultParserRegistry $parserRegistry */
        $parserRegistry = GeneralUtility::makeInstance(ResultParserRegistry::class, /** @scrutinizer ignore-type */ $this->typoScriptConfiguration);
        $useRawDocuments = (bool)$this->typoScriptConfiguration->getValueByPathOrDefaultValue('plugin.tx_solr.features.useRawDocuments', false);
        $parserRegistry->getParser($resultSet)->parse($resultSet, $useRawDocuments);
    }
695186
private void filter(ValueSet filterValueSet, ValueSet valueSet) {
        if (filterValueSet != null && valueSet != null && !filterValueSet.isEmpty() && !valueSet.isEmpty()) {
            Iterator it = filterValueSet.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                if (valueSet.contains(o)) {
                    it.remove();
                }
            }
        }
    }
172940
public function dotAttributeNames()
    {
        return array_merge(
            array_values(parent::fields()),
            array_keys(static::dotKeyValues(static::dynamicColumn(), $this->_dynamicAttributes))
        );
    }
609786
private function resolveTimeValues($valueOrValues)
    {
        if (!is_array($valueOrValues)) {
            return $this->resolveTimeValue($valueOrValues);
        }

        $returnValues = [];

        foreach ($valueOrValues as $key => $value) {
            $returnValues[$key] = $this->resolveTimeValue($value);
        }

        return $returnValues;
    }
1363547
public function setDataBatchBulk(array ...$valuesStack)
    {
        foreach ($valuesStack as $valuesSet) {
            $this->getValuesSetStatement()->setInsertData($valuesSet);
        }
        
        return $this;
    }
522116
public static function fromAttributeValues(AttributeValue ...$values): self
    {
        $attribs = array_map(
            function (AttributeValue $value) {
                return $value->toAttribute();
            }, $values);
        return new self(...$attribs);
    }
945603
public function getInheritedContensetZoneParams(ContentSet $contentSet)
    {
        $zone = null;

        if (
            null === $this->getLayout()
            || null === $this->getParent()
            || false === is_array($this->getLayout()->getZones())
        ) {
            return $zone;
        }

        $layoutZones = $this->getLayout()->getZones();
        $count = $this->getParent()->getContentSet()->count();
        for ($i = 0; $i < $count; $i++) {
            $parentContentset = $this->getParent()->getContentSet()->item($i);

            if ($contentSet->getUid() === $parentContentset->getUid()) {
                $zone = $layoutZones[$i];
            }
        }

        return $zone;
    }