Neos\Media\TypeConverter\ImageInterfaceConverter::applyTypeSpecificHandling PHP Method

applyTypeSpecificHandling() protected method

Converts and adds ImageAdjustments to the ImageVariant
protected applyTypeSpecificHandling ( Neos\Media\Domain\Model\ImageInterface $asset, mixed $source, array $convertedChildProperties, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : Neos\Media\Domain\Model\ImageInterface | null
$asset Neos\Media\Domain\Model\ImageInterface
$source mixed
$convertedChildProperties array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return Neos\Media\Domain\Model\ImageInterface | null
    protected function applyTypeSpecificHandling($asset, $source, array $convertedChildProperties, PropertyMappingConfigurationInterface $configuration)
    {
        if ($asset instanceof ImageVariant) {
            $adjustments = [];
            if (isset($source['adjustments'])) {
                foreach ($source['adjustments'] as $adjustmentType => $adjustmentOptions) {
                    if (isset($adjustmentOptions['__type'])) {
                        $adjustmentType = $adjustmentOptions['__type'];
                        unset($adjustmentOptions['__type']);
                    }
                    $identity = null;
                    if (isset($adjustmentOptions['__identity'])) {
                        $identity = $adjustmentOptions['__identity'];
                        unset($adjustmentOptions['__identity']);
                    }
                    $adjustment = $this->propertyMapper->convert($adjustmentOptions, $adjustmentType, $configuration);
                    if ($identity !== null) {
                        ObjectAccess::setProperty($adjustment, 'persistence_object_identifier', $identity, true);
                    }
                    $adjustments[] = $adjustment;
                }
            } elseif (isset($source['processingInstructions'])) {
                $adjustments = $this->processingInstructionsConverter->convertFrom($source['processingInstructions'], 'array');
            }
            if (count($adjustments) > 0) {
                $asset->addAdjustments($adjustments);
            }
        }
        return $asset;
    }