A Dyfed-Powys Police officer has been dismissed with immediate effect and barred from re-entering the police service after homophobic and racist messages were found on his phone.