How to achieve four quadrant operation of the field oriented control of the three phase induction motor?
The FOC already does all of this. If the motor's actual velocity is higher than it's velocity setpoint, then you will have a generator mode. You can even control the torque with Iq setpoint. For example:
if n&gt;0 // positive direction
  Iq= -Iq_set;  // negative torque (braking)
elseif n&lt;0 // negative direction
  Iq = Iq_set; //positive torque (braking)

The above pseudo algorithm however is yet implemented by simply giving the velecotiy setpoint = 0. If the external load will try to spin the motor, the FOC will brake it.
This is a block scheme of FOC with velocity control. In case you want to have a torque mode only, then you disable the speed controller and you set the torque directly by changing the Iq setpoint. This block is for PMSM, for the induction motor would differ in Id setpoint calulation and it would have an extra rotor flux estimator.