PHP Class Neos\Media\TypeConverter\AssetInterfaceConverter

Inheritance: extends Neos\Flow\Property\TypeConverter\PersistentObjectConverter
Mostrar archivo Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Property Type Description
$assetModelMappingStrategy Neos\Media\Domain\Strategy\AssetModelMappingStrategyInterface
$assetRepository Neos\Media\Domain\Repository\AssetRepository
$defaultNewAssetType string If creating a new asset from this converter this defines the default type as fallback.
$persistenceManager Neos\Flow\Persistence\PersistenceManagerInterface
$priority integer
$resourceManager Neos\Flow\ResourceManagement\ResourceManager
$resourcesAlreadyConvertedToAssets array Maps resource identifiers to assets that already got created during the current request.
$sourceTypes array
$targetType string

Public Methods

Method Description
canConvertFrom ( mixed $source, string $targetType ) : boolean If $source has an identity, we have a persisted Image, and therefore this type converter should withdraw and let the PersistedObjectConverter kick in.
convertFrom ( mixed $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : Error | Neos\Media\Domain\Model\AssetInterface Convert an object from $source to an \Neos\Media\Domain\Model\AssetInterface implementation
getSourceChildPropertiesToBeConverted ( mixed $source ) : array All properties in the source array except __identity and adjustments are sub-properties.
getTargetTypeForSource ( mixed $source, string $originalTargetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string Determines the target type based on the source's (optional) __type key.
getTypeOfChildProperty ( string $targetType, string $propertyName, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : string Convert the property "resource"

Protected Methods

Method Description
applyModelMappingStrategy ( string $originalTargetType, PersistentResource $resource, array $source = [] ) : string Applies the model mapping strategy for a converted resource to determine the final target type.
applyTypeSpecificHandling ( Neos\Media\Domain\Model\AssetInterface $asset, mixed $source, array $convertedChildProperties, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : Neos\Media\Domain\Model\AssetInterface | null
buildObject ( array &$possibleConstructorArgumentValues, string $objectType ) : object Builds a new instance of $objectType with the given $possibleConstructorArgumentValues.
fetchObjectFromPersistence ( mixed $identity, string $targetType ) : object Fetch an object from persistence layer.

Method Details

applyModelMappingStrategy() protected method

The strategy is NOT applied if $source['__type'] is set (overriding was allowed then, otherwise an exception would have been thrown earlier).
protected applyModelMappingStrategy ( string $originalTargetType, PersistentResource $resource, array $source = [] ) : string
$originalTargetType string The original target type determined so far
$resource Neos\Flow\ResourceManagement\PersistentResource The resource that is to be converted to a media file.
$source array the original source properties for this type converter.
return string Class name of the media model to use for the given resource

applyTypeSpecificHandling() protected method

protected applyTypeSpecificHandling ( Neos\Media\Domain\Model\AssetInterface $asset, mixed $source, array $convertedChildProperties, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : Neos\Media\Domain\Model\AssetInterface | null
$asset Neos\Media\Domain\Model\AssetInterface
$source mixed
$convertedChildProperties array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return Neos\Media\Domain\Model\AssetInterface | null

buildObject() protected method

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
protected buildObject ( array &$possibleConstructorArgumentValues, string $objectType ) : object
$possibleConstructorArgumentValues array
$objectType string
return object The created instance

canConvertFrom() public method

If $source has an identity, we have a persisted Image, and therefore this type converter should withdraw and let the PersistedObjectConverter kick in.
public canConvertFrom ( mixed $source, string $targetType ) : boolean
$source mixed The source for the to-build Image
$targetType string Should always be 'Neos\Media\Domain\Model\ImageInterface'
return boolean

convertFrom() public method

Convert an object from $source to an \Neos\Media\Domain\Model\AssetInterface implementation
public convertFrom ( mixed $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : Error | Neos\Media\Domain\Model\AssetInterface
$source mixed
$targetType string must implement 'Neos\Media\Domain\Model\AssetInterface'
$convertedChildProperties array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return Neos\Flow\Validation\Error | Neos\Media\Domain\Model\AssetInterface The converted Asset, a Validation Error or NULL

fetchObjectFromPersistence() protected method

Fetch an object from persistence layer.
protected fetchObjectFromPersistence ( mixed $identity, string $targetType ) : object
$identity mixed
$targetType string
return object

getSourceChildPropertiesToBeConverted() public method

All properties in the source array except __identity and adjustments are sub-properties.
public getSourceChildPropertiesToBeConverted ( mixed $source ) : array
$source mixed
return array

getTargetTypeForSource() public method

Determines the target type based on the source's (optional) __type key.
public getTargetTypeForSource ( mixed $source, string $originalTargetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string
$source mixed
$originalTargetType string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return string

getTypeOfChildProperty() public method

Convert the property "resource"
public getTypeOfChildProperty ( string $targetType, string $propertyName, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : string
$targetType string
$propertyName string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return string

Property Details

$assetModelMappingStrategy protected_oe property

protected AssetModelMappingStrategyInterface,Neos\Media\Domain\Strategy $assetModelMappingStrategy
return Neos\Media\Domain\Strategy\AssetModelMappingStrategyInterface

$assetRepository protected_oe property

protected AssetRepository,Neos\Media\Domain\Repository $assetRepository
return Neos\Media\Domain\Repository\AssetRepository

$defaultNewAssetType protected_oe static_oe property

If creating a new asset from this converter this defines the default type as fallback.
protected static string $defaultNewAssetType
return string

$persistenceManager protected_oe property

protected PersistenceManagerInterface,Neos\Flow\Persistence $persistenceManager
return Neos\Flow\Persistence\PersistenceManagerInterface

$priority protected_oe property

protected int $priority
return integer

$resourceManager protected_oe property

protected ResourceManager,Neos\Flow\ResourceManagement $resourceManager
return Neos\Flow\ResourceManagement\ResourceManager

$resourcesAlreadyConvertedToAssets protected_oe property

Maps resource identifiers to assets that already got created during the current request.
protected array $resourcesAlreadyConvertedToAssets
return array

$sourceTypes protected_oe property

protected array $sourceTypes
return array

$targetType protected_oe property

protected string $targetType
return string