protected function processPermissions(RoleInterface $role, $permissions)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');

        $get = function($entity) {
            /* @var Permission $entity */

            return $entity->getId();
        };

        $delete = function($permission) {
            $this->getDoctrine()->getManager()->remove($permission);
        };

        $update = function($permission, $permissionData) {
            return $this->updatePermission($permission, $permissionData);
        };

        $add = function($permission) use ($role) {
            return $this->addPermission($role, $permission);
        };

        return $restHelper->processSubEntities($role->getPermissions(), $permissions, $get, $add, $update, $delete);
    }