Fire VersionX on MODX API save()

Hello @markh,
is it possible to fire a VersionX snapshot on $xpdo->save()?

Thanks
Jens

Probably not.

If you’re calling save() in your own code, you could also load the versionx service to make a new version directly.

Ah okay, this works great!

$resource = $modx->getObject(...);
$corePath = $modx->getOption('versionx.core_path',null,$modx->getOption('core_path').'components/versionx/');
require_once $corePath.'model/versionx.class.php';
$versionx = new VersionX($modx);
$versionx->newResourceVersion($resource);
1 Like