Ermakov-Lewis symmetry in photonic lattices.