As it was spotted: https://github.com/symfony/symfony-docs/pull/3138#discussion_r7391889, I simply reused parts from http://symfony.com/doc/current/cookbook/security/voters.html#creating-a-custom-voter