@@ -43,17 +43,30 @@ function __construct(VersionX $versionX)
4343 * @param string $value
4444 * @return string
4545 */
46- public static function calculateDiff (string $ prevValue , string $ value ): string
46+ public static function calculateDiff (string $ prevValue , string $ value, array $ options = [] ): string
4747 {
48+ $ renderer = self ::getRenderer ($ options );
4849 return DiffHelper::calculate (
4950 $ prevValue ,
5051 $ value ,
51- ' Inline ' ,
52+ $ renderer ,
5253 self ::$ diffOptions ,
5354 self ::$ rendererOptions ,
5455 );
5556 }
5657
58+ private static function getRenderer (array $ options ): string
59+ {
60+ $ valid = [
61+ 'Inline ' , 'Combined ' , 'SideBySide ' , // HTML
62+ ];
63+ $ renderer = $ options ['renderer ' ] ?? 'Inline ' ;
64+ if (!in_array ($ renderer , $ valid )) {
65+ return 'Inline ' ;
66+ }
67+ return $ renderer ;
68+ }
69+
5770 /**
5871 * @param int $objectId
5972 * @param Type $type
@@ -84,6 +97,9 @@ public function createDelta(int $id, Type $type, bool $isSnapshot = false): ?\vx
8497
8598 // Get current principal object
8699 $ object = $ this ->modx ->getObject ($ type ->getClass (), ['id ' => $ id ]);
100+ $ options = [
101+ 'renderer ' => $ this ->modx ->getOption ('versionx.renderer ' , null , 'Inline ' ),
102+ ];
87103
88104 if (!$ type ->beforeDeltaCreate ($ now , $ object )) {
89105 return null ;
@@ -141,7 +157,7 @@ public function createDelta(int $id, Type $type, bool $isSnapshot = false): ?\vx
141157 }
142158
143159 try {
144- $ renderedDiff = $ fieldTypeObj ->render ($ prevValue , $ value );
160+ $ renderedDiff = $ fieldTypeObj ->render ($ prevValue , $ value, $ options );
145161 }
146162 catch (\Error $ e ) {
147163 $ this ->modx ->log (\modX::LOG_LEVEL_ERROR , '[VersionX] Fatal Error calculating diff: '
@@ -455,4 +471,10 @@ public function removeMilestone(int $deltaId): bool
455471
456472 return false ;
457473 }
474+
475+ public function cleanup (): void
476+ {
477+ $ this ->modx ->log (\xPDO::LOG_LEVEL_INFO , '[VersionX] Cleaning up cache... ' );
478+ $ this ->modx ->cacheManager ->clean (VersionX::CACHE_OPT );
479+ }
458480}
0 commit comments