Creating custom version comparison of Field Types¶
In the Back Office, you can compare the contents of Fields. Comparing is possible only between two versions of the same Field that are in the same language.
You can add the possibility to compare custom and other unsupported Field Types.
You can base the configuration on the comparison mechanism created for the ezstring
Field Type.
Field Type configuration¶
First, ensure that the Field Type to compare implements the EzSystems\EzPlatformVersionComparison\FieldType\Comparable
interface with the following method:
1 2 3 4 5 6 7 |
|
This method fetches the data to compare and determines which comparison engines should be used.
The ComparisonData
object is specific to the Field Type you want to compare.
In case of ezstring
, the implementation is:
1 2 3 4 5 6 7 8 |
|
Also, the Field Type must be registered as a service and tagged as comparable (e.g. config/comparable_fieldtypes.yaml
).
An example configuration, in this case for ezstring
, looks the following way:
1 2 3 |
|
Comparison engine¶
The comparison engine handles the operations required for comparing the contents of Fields. Note that each Field Type requires a separate comparison engine.
When creating a custom engine, ensure that it implements the EzSystems\EzPlatformVersionComparison\Engine\FieldTypeComparisonEngine
interface:
1 2 3 4 5 6 7 8 9 10 11 |
|
The engine must also be registered as a service:
1 2 3 |
|
When configuring the engines, ensure to tag them with both the ezplatform.field_type.comparable.engine
and supported_type
tags.
VersionDiff¶
VersionDiff
is built by VersionComparisonService::compare
.
It consists of an array of EzSystems\EzPlatformVersionComparison\FieldValueDiff
.
It is an object that holds EzSystems\EzPlatformVersionComparison\Result\ComparisonResult
.
It is specific to a Field Type because different Field Types have distinct way of showing the difference between their versions.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|