private function createRegistrationRole($withUserRegisterPolicy = true)
    {
        $roleIdentifier = uniqid(
            'anonymous_role_' . ($withUserRegisterPolicy ? 'with' : 'without') . '_register',
            true
        );

        $roleService = $this->getRepository()->getRoleService();
        $roleCreateStruct = new RoleCreateStruct(['identifier' => $roleIdentifier]);

        $policiesSet = explode(',', EzEnvironmentConstants::get('CREATE_REGISTRATION_ROLE_POLICIES'));
        foreach ($policiesSet as $policy) {
            [$module, $function] = explode('/', $policy);
            $roleCreateStruct->addPolicy($roleService->newPolicyCreateStruct($module, $function));
        }

        if ($withUserRegisterPolicy === true) {
            $roleCreateStruct->addPolicy($roleService->newPolicyCreateStruct('user', 'register'));
        }

        $roleService->publishRoleDraft($roleService->createRole($roleCreateStruct));

        return $roleService->loadRoleByIdentifier($roleIdentifier);
    }