Drupal convention is to use 2 spaces for indent, Symfony convention is to use 4.

I just realized we mixed both conventions for this code which is bad :-(

I don't have much time to adapt everything right now so I guess your change is ok.

Except for that, I need some more time to evaluate your PR. Maybe @lapistano has some time to check it quickly.