Refactoring for Symfony 2.1/2.2 compatibility

Refactored deprecated methods according to https://github.com/symfony/symfony/blob/master/UPGRADE-2.1.md