Energy-level quantization and single-photon control of phase slips in YBa2Cu3O7–x nanowires