In GeoExt, this is done this way to avoid code that would test each kind of layer separately, the encoders are dynamically resolved based on the layer name, see:
https://github.com/geoext/geoext/blob/master/lib/GeoExt/data/PrintProvider.js#L588

In the case of this PR, each layer is still handled separately:
https://github.com/geoadmin/mf-geoadmin3/blob/a3e1f0d2521053d6d109cefaedb087f635d165fc/src/components/print/PrintDirective.js#L47-53