The suggestion bandied around is that EU employment law is so shit that it essentially defers to national employment law of whichever country the company is registered in. In this case Cyprus, which enables fire and rehire.
However, it's also happened very recently in Ireland. Seems it's actually fairly common practice in ferry/maritime business.
So it really is nothing to do with Brexit.