@param string $resourceKey
@param array  $data
@param bool   $includeAttributes

@return array
432741
public function collection($resourceKey, array $data, $includeAttributes = true)
    {
        $resources = [];

        foreach ($data as $resource) {

            /**
             * Add option to override resource key with data.
             */
            if (is_array($resource) && array_key_exists('_resource_key', $resource)) {
                $resourceKey = $resource['_resource_key'];
                unset($resource['_resource_key']);
            }

            $resources[] = $this->item($resourceKey, $resource, $includeAttributes)['data'];
        }

        return ['data' => $resources];
    }
1160319
protected function mapAttributes(array &$data)
    {
        $map = $this->attributeMap;
        $out = [];

        foreach ($data as $key => &$value) {
            if (isset($map[$key])) {
                $key = $map[$key];
            }
            $out[$key] = $value;
        }

        return $out;
    }
555944
public function getRequestData($includeQueryParameters = true)
    {
        $requestData = array();
        if ($this->restApiRequestMethod == 'PUT' || $this->restApiRequestMethod == 'PATCH' || $this->restApiRequestMethod == 'POST') {
            $requestData = array_merge($this->restApiPostData, array(Defaults::$fullRequestDataName => $this->restApiPostData));
        }

        if ($includeQueryParameters === true) {
            return $requestData + $this->restApiGetData;
        }
        return $requestData;
    }
662212
public function normalize($data, Resource $resource)
    {
        if (isset($data['value']['map'])) {
            $options = isset($data['value']['map']['options']) ? $data['value']['map']['options'] : [];
            $data['value']['map'] = $this->normalizer->normalize(
                [
                    'key'   => $data['value']['map']['validator'],
                    'value' => $options,
                ],
                $resource
            );
        }

        return $this->createDefinition($data['value']);
    }
101173
public function processIncludedResources(Scope $scope, $data)
    {
        $includedData = [];

        $includes = $this->figureOutWhichIncludes($scope);

        foreach ($includes as $include) {
            $includedData = $this->includeResourceIfAvailable(
                $scope,
                $data,
                $includedData,
                $include
            );
        }

        return $includedData === [] ? false : $includedData;
    }
261416
public function withItem($data, $transformer, $resourceKey = null, $meta = [], array $headers = [])
    {
        $resource = new Item($data, $transformer, $resourceKey);

        foreach ($meta as $metaKey => $metaValue) {
            $resource->setMetaValue($metaKey, $metaValue);
        }

        $rootScope = $this->manager->createData($resource);

        return $this->withArray($rootScope->toArray(), $headers);
    }
277796
private function checkDataSet(array $data, $key, $isNew)
    {
        $keyExists = array_key_exists($key, $data);

        if (($isNew && !($keyExists && $data[$key] !== null)) || (!$keyExists || $data[$key] === null)) {
            throw new MissingShippingAttributeException($key);
        }

        return $keyExists;
    }
767519
public function update($resourceType, $name, $data)
    {
        return $this->client()->put($data, 'custom-fields/{resourceType}/{name}', [
            'resourceType' => $resourceType,
            'name' => $name,
        ]);
    }
735188
private static function buildPluginData($key, $data){
        if (is_array($data)) {
            $name = $key;
            $attributes = $data;
        } else {
            $name = $data;
            $attributes = [];
        }
        return [
            'name' => $name,
            'attributes' => $attributes
        ];
    }
1024821
public function collection($resourceKey, array $data)
    {
        if (is_null($resourceKey)) $resourceKey = static::RESOURCE_KEY;
        return $resourceKey ? [$resourceKey => $data]: $data;
    }
1230064
private function getHydraProperties(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array $context): array
    {
        $classes = [];
        foreach ($resourceMetadata->getCollectionOperations() as $operationName => $operation) {
            $inputMetadata = $resourceMetadata->getTypedOperationAttribute(OperationType::COLLECTION, $operationName, 'input', ['class' => $resourceClass], true);
            if (null !== $inputClass = $inputMetadata['class'] ?? null) {
                $classes[$inputClass] = true;
            }

            $outputMetadata = $resourceMetadata->getTypedOperationAttribute(OperationType::COLLECTION, $operationName, 'output', ['class' => $resourceClass], true);
            if (null !== $outputClass = $outputMetadata['class'] ?? null) {
                $classes[$outputClass] = true;
            }
        }

        $properties = [];
        foreach ($classes as $class => $v) {
            foreach ($this->propertyNameCollectionFactory->create($class, $this->getPropertyNameCollectionFactoryContext($resourceMetadata)) as $propertyName) {
                $propertyMetadata = $this->propertyMetadataFactory->create($class, $propertyName);
                if (true === $propertyMetadata->isIdentifier() && false === $propertyMetadata->isWritable()) {
                    continue;
                }

                if ($this->nameConverter) {
                    $propertyName = $this->nameConverter->normalize($propertyName, $class, self::FORMAT, $context);
                }

                $properties[] = $this->getProperty($propertyMetadata, $propertyName, $prefixedShortName, $shortName);
            }
        }

        return $properties;
    }
62027
public function collection($resourceKey, array $data)
    {
        $resources = [];

        foreach ($data as $resource) {
            $resources[] = $this->item($resourceKey, $resource)['data'];
        }

        return ['data' => $resources];
    }
127588
public function addDataAttributes(array $dataAttributes)
    {
        foreach ($dataAttributes as $name => $value) {
            $this->addDataAttribute($name, $value);
        }
        return $this;
    }
304472
function resolveDataSourceAttributes(resourceTree, dataSources, primaryName) {
    Object.keys(dataSources).forEach(dataSourceName => {
        const dataSource = dataSources[dataSourceName];
        dataSource.attributes = [];
        dataSource.attributeOptions = {};
    });

    resourceTree.attributes.forEach(function resolveAttribute(attrInfo) {
        let selectedDataSources;

        if (attrInfo.fromDataSource === '#same-group') {
            return attrInfo.attributes.forEach(resolveAttribute); // handle key-groups as flat
        }

        if (attrInfo.fromDataSource === '#all-selected') {
            attrInfo.attrNode.selectedDataSource = primaryName;
            selectedDataSources = [];
            Object.keys(dataSources).forEach(dataSourceName => {
                if (dataSources[dataSourceName].joinParentKey) return;
                selectedDataSources.push(dataSourceName);
            });
        } else if (attrInfo.fromDataSource === '#current-primary') {
            attrInfo.attrNode.selectedDataSource = primaryName;
            selectedDataSources = [attrInfo.attrNode.selectedDataSource];
        } else if (attrInfo.fromDataSource) {
            attrInfo.attrNode.selectedDataSource = attrInfo.fromDataSource;
            selectedDataSources = [attrInfo.attrNode.selectedDataSource];
        } else {
            attrInfo.attrNode.selectedDataSource = Object.keys(attrInfo.dataSourceMap).find(
                dataSourceName => dataSources[dataSourceName]
            );

            if (!attrInfo.attrNode.selectedDataSource) {
                throw new ImplementationError(
                    'No proper DataSource selected for attribute ' +
                        '(this should not happen - bug in request-resolver in Flora core)'
                );
            }
            selectedDataSources = [attrInfo.attrNode.selectedDataSource];
        }

        selectedDataSources.forEach(selectedDataSourceName => {
            const attribute = attrInfo.dataSourceMap[selectedDataSourceName];
            dataSources[selectedDataSourceName].attributes.push(attribute);
            dataSources[selectedDataSourceName].attributeOptions[attribute] = _.pick(attrInfo.attrNode, [
                'type',
                'storedType',
                'multiValued',
                'delimiter'
            ]);
        });

        return null;
    });

    Object.keys(dataSources).forEach(dataSourceName => {
        dataSources[dataSourceName].attributes = _.uniq(dataSources[dataSourceName].attributes);
    });
}
756199
protected function wrapData($dataArray, $dataKey = null)
    {
        if (!$dataKey) $dataKey = $this->getResourcePostKey();

        return array($dataKey => $dataArray);
    }
403797
public function mergeInclude(array $data, array $includeData): array
    {
        foreach ($data as $class => $fixtures) {
            // $class is either a FQCN or 'parameters'
            $includeData[$class] = (
                    array_key_exists($class, $includeData)
                    && is_array($includeData[$class])
                    && is_array($fixtures)
                )
                ? array_merge($includeData[$class], $fixtures)
                : $fixtures
            ;
        }

        return $includeData;
    }
247414
protected static function common_check(&$attributes, $include_method = true)
    {
        if (!empty($attributes['args'])) {
            $attributes['data-phery-args'] = json_encode($attributes['args']);
            unset($attributes['args']);
        }

        if (!empty($attributes['confirm'])) {
            $attributes['data-phery-confirm'] = $attributes['confirm'];
            unset($attributes['confirm']);
        }

        if (!empty($attributes['cache'])) {
            $attributes['data-phery-cache'] = "1";
            unset($attributes['cache']);
        }

        if (!empty($attributes['target'])) {
            $attributes['data-phery-target'] = $attributes['target'];
            unset($attributes['target']);
        }

        if (!empty($attributes['related'])) {
            $attributes['data-phery-related'] = $attributes['related'];
            unset($attributes['related']);
        }

        if (!empty($attributes['phery-type'])) {
            $attributes['data-phery-type'] = $attributes['phery-type'];
            unset($attributes['phery-type']);
        }

        if (!empty($attributes['only'])) {
            $attributes['data-phery-only'] = $attributes['only'];
            unset($attributes['only']);
        }

        if (isset($attributes['clickable'])) {
            $attributes['data-phery-clickable'] = "1";
            unset($attributes['clickable']);
        }

        if ($include_method) {
            if (isset($attributes['method'])) {
                $attributes['data-phery-method'] = $attributes['method'];
                unset($attributes['method']);
            }
        }

        $encoding = 'UTF-8';
        if (isset($attributes['encoding'])) {
            $encoding = $attributes['encoding'];
            unset($attributes['encoding']);
        }

        return $encoding;
    }