Serialize Asset-Data
Overview
The bundle offers a "FieldSerializer" service. It can be used to serialize fields with asset data before exporting, this can be useful for export adapters.
Namespace
The service can be located here: Twocream\ShopwareConnectorBundle\Serializer\FieldSerializer
Methods
The service offers serialization methods for the following data types:
Asset
Name: serializeAsset
Output: An array of asset data with the following entries: 'mimetype', 'filename', 'path', 'modification-date', 'size', 'translations', 'thumbnails'
Arguments:
| Name & Data Type | Mandatory | Description |
|---|---|---|
?Asset $asset | Yes | The Asset object that is to be serialized. |
AssetHelper $assetHelper | Yes | An instance of the AssetHelper class. See: Asset Helper. |
array $thumbnailNames | No - Default: [] | Specifies the thumbnails for which the asset should be generated. |
array $metaFieldMapping | No - Default: [] | A mapping for differing metadata names. By default the service assumes the names "title", "alt" & "copyright". If the actual metadata names differ from this, you can specify it here (e.g., ['title' => 'name'] if the metadata value for the title is actually called "name"). |
string $folder | No - Default: 'media' | Optional subfolder within the defined asset path where the generated files will be stored. |
?array $languages | No - Default: null | A list of languages used for metadata translations. |
ImageGallery
Name: serializeImageGalleryField
Output: An array with entries for each image in the gallery. Each entry contains an array with the following entries: 'mimetype', 'filename', 'path', 'modification-date', 'size', 'translations', 'thumbnails'
Arguments:
| Name & Data Type | Mandatory | Description |
|---|---|---|
?ImageGallery $imageGallery | Yes | The ImageGallery object that is to be serialized. |
AssetHelper $assetHelper | Yes | An instance of the AssetHelper class. See: Asset Helper. |
array $thumbnailNames | No - Default: [] | Specifies the thumbnails for which the asset should be generated. |
array $metaFieldMapping | No - Default: [] | A mapping for differing metadata names. By default the service assumes the names "title", "alt" & "copyright". If the actual metadata names differ from this, you can specify it here (e.g., ['title' => 'name'] if the metadata value for the title is actually called "name"). |
string $folder | No - Default: 'media' | Optional subfolder within the defined asset path where the generated files will be stored. |
?array $languages | No - Default: null | A list of languages used for metadata translations. |
Video
Name: serializeVideoField
Output: An array of video data with the following entries: 'type', 'title', 'description', 'date', 'youtube-id'
Arguments:
| Name & Data Type | Mandatory | Description |
|---|---|---|
?AbstractObject $videoObject | Yes | The DataObject which contains the video field that is to be serialized. |
string $videoFieldIdentifier | Yes | The field name of the video field. |
array $fieldMapping | Yes | A mapping for differing names of video data fields. By default the service assumes the names "title", "description" & "date". If the actual field names differ from this, you can specify it here (e.g., ['title' => 'name'] if the title field is actually named "name"). |
?string $language | No - Default: null | The language used for the video data. This is only necessary if the field is localized. |
Video (Multi-Language)
Name: serializeMultiLanguageVideoField
Output: An array with the entry 'translations'. This contains an array with video data for each language. Each language entry has the following data entries: 'type', 'title', 'description', 'date', 'youtube-id'
Arguments:
| Name & Data Type | Mandatory | Description |
|---|---|---|
?AbstractObject $videoObject | Yes | The DataObject which contains the video field that is to be serialized. |
string $videoFieldIdentifier | Yes | The field name of the video field. |
array $fieldMapping | Yes | A mapping for differing names of video data fields. By default the service assumes the names "title", "description" & "date". If the actual field names differ from this, you can specify it here (e.g., ['title' => 'name'] if the title field is actually named "name"). |
array $languages | Yes | A list of languages the video data should be serialized in. |
?string $defaultVideoFieldIdentifier | No - Default: null | The default field name of a video field whose data should be used if no data is found for a language. The default language is used here. |
?string $defaultLanguage | No - Default: null | The language for which data should be obtained from the default field if no data is found for a language. |