public function isRoleScopePresentOnce(ExecutionContextInterface $context) 
    {
        $roleScopesId = array_map(function(RoleScope $roleScope) {
                    return $roleScope->getId();
                }, 
                $this->getRoleScopes()->toArray());
        $countedIds = array_count_values($roleScopesId);
        
        foreach ($countedIds as $id => $nb) {
            if ($nb > 1) {
                $context->buildViolation("A permission is already present "
                        . "for the same role and scope")
                        ->addViolation();
            }
        }
    }
public function isRoleScopePresentOnce(ExecutionContextInterface $context) 
    {
        $roleScopesId = array_map(function(RoleScope $roleScope) {
                    return $roleScope->getId();
                }, 
                $this->getRoleScopes()->toArray());
        $countedIds = array_count_values($roleScopesId);
        
        foreach ($countedIds as $id => $nb) {
            if ($nb > 1) {
                $context->buildViolation("A permission is already present "
                        . "for the same role and scope")
                        ->addViolation();
            }
        }
    }
public function isRoleScopePresentOnce ( ExecutionContextInterface $ context ) { $ roleScopesId = array_map ( function ( RoleScope $ roleScope ) { return $ roleScope -> getId ( ) ; } , $ this -> getRoleScopes ( ) -> toArray ( ) ) ; $ countedIds = array_count_values ( $ roleScopesId ) ; foreach ( $ countedIds as $ id => $ nb ) { if ( $ nb > 1 ) { $ context -> buildViolation ( "A permission is already present " . "for the same role and scope" ) -> addViolation ( ) ; } } }
Test that a role scope is associated only once with the permission group

@param ExecutionContextInterface $context
Test that a role scope is associated only once with the permission group