We analyze the coherent transport of a single photon, which propagates in a one-dimensional coupled-resonator waveguide and is scattered by a controllable two-level system located inside one of the resonators of this waveguide. Our approach, which uses discrete coordinates, unifies low and high energy effective theories for single-photon scattering. We show that the controllable two-level system can behave as a quantum switch for the coherent transport of a single photon. This study may inspire new electro-optical single-photon quantum devices. We also suggest an experimental setup based on superconducting transmission line resonators and qubits.