I would rather have used the [Finder component](http://symfony.com/doc/2.3/components/finder.html) for this, more reliable IMHO.