This way an environment selected in the GUI and an environment selected in kickstart are treated in the same way. This fixes the problem where changing payloads forgets the previous environment selection, and it changes the generated %packages section of anaconda-ks.cfg to contain the environment information instead of a list of the groups in the environment.
This commit restores the dnf _select_environment method removed in 602f47dcd5d7543f66dc6833685d0e810595acb5, but modifies it so that the environment is both selected in dnf and in the kickstart data.