This code should not be copied from the hook.core project instead we should just refactor the code there in that plugin to make it possible to call it from this class.