Refactor Permissions module to Doctrine