@param DataInterface      $object
@param AttributeInterface $attribute
@param mixed              $rawValue
@param array              $context

@return array
974677
protected function getEAVAttributeContext(
        DataInterface $object,
        AttributeInterface $attribute,
        /* @noinspection PhpUnusedParameterInspection */
        $rawValue,
        array $context
    ) {
        $resolvedContext = parent::getEAVAttributeContext($object, $attribute, $rawValue, $context);

        if (!\is_object($rawValue)) {
            return $resolvedContext;
        }

        $resolvedContext['resource_class'] = ClassUtils::getClass($rawValue);
        unset($resolvedContext['item_operation_name'], $resolvedContext['collection_operation_name']);

        return $resolvedContext;
    }
795600
private function processSerializeTypeCollectionObject($objectType, $object, array $data, string $attribute): array
    {
        $subData = $object->{$objectType->getter()}();
        if ($this->checkNullForAttribute($subData, $attribute) === true) {
            return $data;
        }

        foreach ($subData as $key => $subObject) {
            $data = $this->setArrayAndCheckNullWithKey($data, $subObject, $key, $attribute);
        }

        return $data;
    }
1051219
public function normalize($object, $format = null, array $context = [])
    {
        if (null !== $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {
            return parent::normalize($object, $format, $context);
        }

        $data = parent::normalize($object, $format, $context);
        if (!\is_array($data)) {
            throw new UnexpectedValueException('Expected data to be an array');
        }

        $data[self::ITEM_RESOURCE_CLASS_KEY] = $this->getObjectClass($object);
        $data[self::ITEM_IDENTIFIERS_KEY] = $this->identifiersExtractor->getIdentifiersFromItem($object);

        return $data;
    }
680440
protected static function reqGetResourceAttributes(ContextInterface $context): array
    {
        assert(static::reqHasResourceAttributes($context));

        $value = $context->getRequest()->get(RequestProperties::REQ_RESOURCE_ATTRIBUTES);

        assert(is_array($value));

        return $value;
    }
861412
protected function getInternalValues(AttributeInterface $attribute = null, array $context = null)
    {
        if ($context) {
            $context = array_merge($this->getCurrentContext(), $context);
        } else {
            $context = $this->getCurrentContext();
        }

        if (null === $attribute) {
            $values = new ArrayCollection();
            foreach ($this->values as $value) {
                if (!$this->getFamily()->hasAttribute($value->getAttributeCode())) {
                    $this->removeValue($value);
                    continue;
                }
                $attribute = $this->getFamily()->getAttribute($value->getAttributeCode());
                if ($attribute->isContextMatching($value, $context)) {
                    $values->add($value);
                }
            }

            return $values;
        }
        $this->checkAttribute($attribute);

        $values = new ArrayCollection();
        foreach ($this->getValuesByAttribute($attribute) as $value) {
            if ($value instanceof ContextualValueInterface) {
                if ($attribute->isContextMatching($value, $context)) {
                    $values->add($value);
                }
            } else {
                $values->add($value);
            }
        }

        return $values;
    }
846205
protected function createNormalizedArray(array $rawPayload, AdapterInterface $adapter)
    {
        $metadata = $this->extractMetadata($rawPayload, $adapter);
        // @todo Should this be wrapped in an object, or is a hash fine?
        return [
            'id'            => $this->extractId($rawPayload),
            'type'          => $metadata->type,
            'properties'    => $this->extractProperties($rawPayload, $metadata)
        ];
    }
137616
public function getDataFromRequestQuery(
        ServerRequestInterface $request,
        $object,
        DenormalizerContextInterface $context = null
    ) {
        return $this->deserializer->denormalize($object, $request->getQueryParams(), $context);
    }
774007
protected function getExpectedValue($rawExpectedValue, $typeExpectedValue)
    {
        $result = @settype($rawExpectedValue, $typeExpectedValue);

        if (!$result) {
            throw new Exception\InvalidConvertTypeException('Invalid convert type');
        }

        return $rawExpectedValue;
    }
1092771
public function convert(NodeType $nodeType, $propertyName, $rawValue, Context $context)
    {
        $propertyType = $nodeType->getPropertyType($propertyName);

        switch ($propertyType) {
            case 'string':
                return $rawValue;

            case 'reference':
                return $this->convertReference($rawValue, $context);

            case 'references':
                return $this->convertReferences($rawValue, $context);

            case 'DateTime':
                return $this->convertDateTime($rawValue);

            case 'integer':
                return $this->convertInteger($rawValue);

            case 'boolean':
                return $this->convertBoolean($rawValue);

            case 'array':
                return $this->convertArray($rawValue);

            default:
                $innerType = $propertyType;
                if ($propertyType !== null) {
                    try {
                        $parsedType = TypeHandling::parseType($propertyType);
                        $innerType = $parsedType['elementType'] ?: $parsedType['type'];
                    } catch (InvalidTypeException $exception) {
                    }
                }

                if ((is_string($rawValue) || is_array($rawValue)) && $this->objectManager->isRegistered($innerType) && $rawValue !== '') {
                    $propertyMappingConfiguration = new MvcPropertyMappingConfiguration();
                    $propertyMappingConfiguration->allowOverrideTargetType();
                    $propertyMappingConfiguration->allowAllProperties();
                    $propertyMappingConfiguration->skipUnknownProperties();
                    $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
                    $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);

                    return $this->propertyMapper->convert($rawValue, $propertyType, $propertyMappingConfiguration);
                } else {
                    return $rawValue;
                }
        }
    }
923504
public function normalize($object, $format = null, array $context = [])
    {
        if (isset($context['api_resource'])) {
            $originalResource = $context['api_resource'];
            unset($context['api_resource']);
        }

        $data = $this->decorated->normalize($object, $format, $context);
        if (!\is_array($data)) {
            throw new UnexpectedValueException('Expected data to be an array');
        }

        // when using an output class, get the IRI from the resource
        if (isset($originalResource) && isset($data['id'])) {
            $data['_id'] = $data['id'];
            $data['id'] = $this->iriConverter->getIriFromItem($originalResource);
        }

        $data[self::ITEM_RESOURCE_CLASS_KEY] = $this->getObjectClass($object);
        $data[self::ITEM_IDENTIFIERS_KEY] = $this->identifiersExtractor->getIdentifiersFromItem($object);

        return $data;
    }
802893
private function assignCsvAttributes(ObjectInterface $object, array $csvAttributes, ImportResult $importResult)
    {
        $attributesWarnings = $this->app->build(ErrorList::class);
        /* @var ErrorList $attributesWarnings */
        $attributeKeysAndControllers = $this->getAttributeKeysAndControllers();
        $result = array_fill(0, count($attributeKeysAndControllers), null);
        foreach ($csvAttributes as $attributeIndex => $attributeData) {
            list($attributeKey, $attributeController) = $attributeKeysAndControllers[$attributeIndex];
            /* @var \Concrete\Core\Attribute\AttributeKeyInterface $attributeKey */
            /* @var \Concrete\Core\Attribute\Controller $attributeController */
            $initialValueObject = $object->getAttributeValueObject($attributeKey, false);
            $attributeController->setAttributeValue($initialValueObject);
            $data = $this->convertCsvDataForAttributeController($attributeController, $attributeData);
            if ($attributeController instanceof SimpleTextExportableAttributeInterface) {
                $newValueObject = $attributeController->updateAttributeValueFromTextRepresentation($data, $attributesWarnings);
            } elseif ($attributeController instanceof MulticolumnTextExportableAttributeInterface) {
                $newValueObject = $attributeController->updateAttributeValueFromTextRepresentation($data, $attributesWarnings);
            } else {
                $newValueObject = null;
            }
            if ($newValueObject !== null && $this->dryRun === false) {
                if ($newValueObject === $initialValueObject) {
                    $this->entityManager->flush();
                } else {
                    $object->setAttribute($attributeKey, $newValueObject);
                }
            }
            $result[$attributeIndex] = $newValueObject;
        }
        foreach ($attributesWarnings->getList() as $warning) {
            if ($warning instanceof Exception || $warning instanceof Throwable) {
                $warning = $warning->getMessage();
            } else {
                $warning = (string) $warning;
            }
            $importResult->addLineProblem(false, $warning);
        }

        return $result;
    }
646913
public function normalize($object, $format = null, array $context = [])
    {
        $resourceClass = $this->resourceClassResolver->getResourceClass(
            $object,
            $context['resource_class'] ?? null,
            true
        );
        $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
        $data = $this->addJsonLdContext($this->contextBuilder, $resourceClass, $context);

        $rawData = parent::normalize($object, $format, $context);
        if (!\is_array($rawData)) {
            return $rawData;
        }

        $data['@id'] = $this->iriConverter->getIriFromItem($object);
        $data['@type'] = $resourceMetadata->getIri() ?: $resourceMetadata->getShortName();

        return $data + $rawData;
    }
978849
private function getPopulatedRelations($object, ?string $format, array $context, array $relationships): array
    {
        $data = [];

        if (!isset($context['resource_class'])) {
            return $data;
        }

        unset($context['api_included']);
        foreach ($relationships as $relationshipDataArray) {
            $relationshipName = $relationshipDataArray['name'];

            $attributeValue = $this->getAttributeValue($object, $relationshipName, $format, $context);

            if ($this->nameConverter) {
                $relationshipName = $this->nameConverter->normalize($relationshipName, $context['resource_class'], self::FORMAT, $context);
            }

            if (!$attributeValue) {
                continue;
            }

            $data[$relationshipName] = [
                'data' => [],
            ];

            // Many to one relationship
            if ('one' === $relationshipDataArray['cardinality']) {
                unset($attributeValue['data']['attributes']);
                $data[$relationshipName] = $attributeValue;

                continue;
            }

            // Many to many relationship
            foreach ($attributeValue as $attributeValueElement) {
                if (!isset($attributeValueElement['data'])) {
                    throw new UnexpectedValueException(sprintf('The JSON API attribute \'%s\' must contain a "data" key.', $relationshipName));
                }
                unset($attributeValueElement['data']['attributes']);
                $data[$relationshipName]['data'][] = $attributeValueElement['data'];
            }
        }

        return $data;
    }
1254204
protected function initializeState(RawLayout $rawLayout, ContextInterface $context)
    {
        $this->rawLayout = $rawLayout;
        $this->context   = $context;

        $this->dataAccessor    = new DataAccessor($this->registry, $this->context);
        $this->optionsResolver = new BlockOptionsResolver($this->registry);
        $this->typeHelper      = new BlockTypeHelper($this->registry);
        $this->blockBuilder    = new BlockBuilder(
            $this->layoutManipulator,
            $this->rawLayout,
            $this->typeHelper,
            $this->context
        );
        $this->block           = new Block(
            $this->rawLayout,
            $this->typeHelper,
            $this->context,
            $this->dataAccessor
        );
    }
299999
public function hydrateObject($object, $data, $class, $format, $context)
    {
        $attributes = $this->getAttributes($class, $format, $context);
        foreach ($attributes as $attribute) {
            $value = isset($data[$attribute]) ? $data[$attribute] : null;
            $value = $this->denormalizeProperty($value, null, $attribute, $format, $context);

            $this->setAttributeValue($object, $attribute, $value, $format, $context);
        }

        return $object;
    }
225733
public function getAttributes($objectOrClass, $format = null, array $context)
    {
        $class = is_object($objectOrClass) ? get_class($objectOrClass) : $objectOrClass;

        /** @var ClassMetadata $meta */
        $meta = $this->entityMetadataFactory->getMetadataFor($class);

        $fields = array_keys($meta->fieldMappings);
        $fields = array_filter($fields, function ($name) { return strpos($name, '.') === false; });
        $embedded = array_keys($meta->embeddedClasses);
        $associations = array_keys($meta->associationMappings);

        return array_merge($fields, $embedded, $associations);
    }
1357652
private function setArrayAndCheckNullWithKey(array $data, $object, $key, $attribute): array
    {
        $value = $this->setArray($object);

        if ($this->checkNullForAttribute($value, $key) === false) {
            $data[$attribute][$key] = $value;
        }

        return $data;
    }