These are the ugly parts. IMHO it can be refactored with DI somehow. Personally I would leave that to the time of resolving:
ARQGRA-302 - page fragments injectable by interfaces