Implementing Mplus's approach to reflection invariance (factor analysis)

One of the most effective controls for reflection invariance in Bayesian factor analysis that I’ve encountered is implemented in Mplus - to the point that I didn’t know about the issue of reflection invariance until I started attempting factor analyses in JAGS and Stan.

After contacting Mplus support to ask about their control for reflection invariance, I got this response:

In each MCMC iteration if the sum of the positive loadings is smaller than the sum of the negative loadings by absolute value, we reverse the sign of the factor so that the sum of the positive loadings is always greater than the sum of the negative loadings by absolute value. It is implicit parameter constraint that is implemented internally.

For implementing this in Stan, the best I can think of is to loop through each column of the loading matrix and manually reverse the sign of the latent variable:

parameters {
  matrix[E,J] loadings;    //E latent variables, J observed items
  matrix[E,N] eta;         //E latent variables, N individuals
}

transformed parameters {
  matrix[E,N] eta_invar = eta;

  for (e in 1:E){
    if (sum(loadings[e] < 0.0)
      eta_invar[e] *= -1.0;
  }
}

Is there a more efficient way to code this up or is this the best that I’ll be able to do?