class ImageConverter extends ImageInterfaceConverter (View source)

This converter transforms to \Neos\Media\Domain\Model\Image objects.

Constants

CONFIGURATION_ONE_PER_RESOURCE

Properties

protected array $sourceTypes from  AssetInterfaceConverter
protected string $targetType
protected int $priority
protected AssetRepository $assetRepository from  AssetInterfaceConverter
protected PersistenceManagerInterface $persistenceManager from  AssetInterfaceConverter
protected AssetModelMappingStrategyInterface $assetModelMappingStrategy from  AssetInterfaceConverter
protected ResourceManager $resourceManager from  AssetInterfaceConverter
static protected string $defaultNewAssetType

If creating a new asset from this converter this defines the default type as fallback.

from  ImageInterfaceConverter
protected array $resourcesAlreadyConvertedToAssets

Maps resource identifiers to assets that already got created during the current request.

from  AssetInterfaceConverter
protected ProcessingInstructionsConverter $processingInstructionsConverter from  ImageInterfaceConverter
protected PropertyMapper $propertyMapper from  ImageInterfaceConverter

Methods

bool
canConvertFrom(mixed $source, string $targetType)

If $source has an identity, we have a persisted Image, and therefore this type converter should withdraw and let the PersistedObjectConverter kick in.

array
getSourceChildPropertiesToBeConverted(mixed $source)

All properties in the source array except __identity are sub-properties.

string
getTypeOfChildProperty(string $targetType, string $propertyName, PropertyMappingConfigurationInterface $configuration)

Convert the property "resource"

string
getTargetTypeForSource(mixed $source, string $originalTargetType, PropertyMappingConfigurationInterface $configuration = null)

Determines the target type based on the source's (optional) __type key.

convertFrom(mixed $source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)

Convert an object from $source to an \Neos\Media\Domain\Model\AssetInterface implementation

object
buildObject(array $possibleConstructorArgumentValues, string $objectType)

Builds a new instance of $objectType with the given $possibleConstructorArgumentValues.

object
fetchObjectFromPersistence(mixed $identity, string $targetType)

Fetch an object from persistence layer.

applyTypeSpecificHandling(AssetInterface $asset, mixed $source, array $convertedChildProperties, PropertyMappingConfigurationInterface $configuration)

Converts and adds ImageAdjustments to the ImageVariant

string
applyModelMappingStrategy(string $originalTargetType, PersistentResource $resource, array $source = [])

Applies the model mapping strategy for a converted resource to determine the final target type.

Details

bool canConvertFrom(mixed $source, string $targetType)

If $source has an identity, we have a persisted Image, and therefore this type converter should withdraw and let the PersistedObjectConverter kick in.

Parameters

mixed $source

The source for the to-build Image

string $targetType

Should always be 'Neos\Media\Domain\Model\ImageInterface'

Return Value

bool

array getSourceChildPropertiesToBeConverted(mixed $source)

All properties in the source array except __identity are sub-properties.

Parameters

mixed $source

Return Value

array

string getTypeOfChildProperty(string $targetType, string $propertyName, PropertyMappingConfigurationInterface $configuration)

Convert the property "resource"

Parameters

string $targetType
string $propertyName
PropertyMappingConfigurationInterface $configuration

Return Value

string

string getTargetTypeForSource(mixed $source, string $originalTargetType, PropertyMappingConfigurationInterface $configuration = null)

Determines the target type based on the source's (optional) __type key.

Parameters

mixed $source
string $originalTargetType
PropertyMappingConfigurationInterface $configuration

Return Value

string

Exceptions

InvalidDataTypeException
InvalidPropertyMappingConfigurationException
InvalidArgumentException

Error|AssetInterface convertFrom(mixed $source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)

Convert an object from $source to an \Neos\Media\Domain\Model\AssetInterface implementation

Parameters

mixed $source
string $targetType

must implement 'Neos\Media\Domain\Model\AssetInterface'

array $convertedChildProperties
PropertyMappingConfigurationInterface $configuration

Return Value

Error|AssetInterface

The converted Asset, a Validation Error or NULL

Exceptions

InvalidTargetException

protected object buildObject(array $possibleConstructorArgumentValues, string $objectType)

Builds a new instance of $objectType with the given $possibleConstructorArgumentValues.

If constructor argument values are missing from the given array the method looks for a default value in the constructor signature.

Furthermore, the constructor arguments are removed from $possibleConstructorArgumentValues

Parameters

array $possibleConstructorArgumentValues
string $objectType

Return Value

object

The created instance

Exceptions

InvalidTargetException

protected object fetchObjectFromPersistence(mixed $identity, string $targetType)

Fetch an object from persistence layer.

Parameters

mixed $identity
string $targetType

Return Value

object

Exceptions

TargetNotFoundException
InvalidSourceException

protected AssetInterface|null applyTypeSpecificHandling(AssetInterface $asset, mixed $source, array $convertedChildProperties, PropertyMappingConfigurationInterface $configuration)

Converts and adds ImageAdjustments to the ImageVariant

Parameters

AssetInterface $asset
mixed $source
array $convertedChildProperties
PropertyMappingConfigurationInterface $configuration

Return Value

AssetInterface|null

protected string applyModelMappingStrategy(string $originalTargetType, PersistentResource $resource, array $source = [])

Applies the model mapping strategy for a converted resource to determine the final target type.

The strategy is NOT applied if $source['__type'] is set (overriding was allowed then, otherwise an exception would have been thrown earlier).

Parameters

string $originalTargetType

The original target type determined so far

PersistentResource $resource

The resource that is to be converted to a media file.

array $source

the original source properties for this type converter.

Return Value

string

Class name of the media model to use for the given resource