Entity/User.php
public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
    {
        $groupCentersIds = array();
        foreach ($this->getGroupCenters() as $groupCenter) {
            if (in_array($groupCenter->getId(), $groupCentersIds)) {
                $context->buildViolation("The user has already those permissions")
                        ->addViolation();
                
            } else {
                $groupCentersIds[] = $groupCenter->getId();
            }
        }
    }
public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
    {
        $groupCentersIds = array();
        foreach ($this->getGroupCenters() as $groupCenter) {
            if (in_array($groupCenter->getId(), $groupCentersIds)) {
                $context->buildViolation("The user has already those permissions")
                        ->addViolation();
                
            } else {
                $groupCentersIds[] = $groupCenter->getId();
            }
        }
    }
public function isGroupCenterPresentOnce ( ExecutionContextInterface $ context ) { $ groupCentersIds = array ( ) ; foreach ( $ this -> getGroupCenters ( ) as $ groupCenter ) { if ( in_array ( $ groupCenter -> getId ( ) , $ groupCentersIds ) ) { $ context -> buildViolation ( "The user has already those permissions" ) -> addViolation ( ) ; } else { $ groupCentersIds [ ] = $ groupCenter -> getId ( ) ; } } }
This function check that groupCenter are present only once. The validator
use this function to avoid a user to be associated to the same groupCenter
more than once.
This function check that groupCenter are present only once . The validator use this function to avoid a user to be associated to the same groupCenter more than once .