main/core/Validator/Constraints/UserAdministrativeCodeValidator.php
public function validate($user, Constraint $constraint)
    {
        $code = $user->getAdministrativeCode();
        if (!empty($code) && $this->platformConfigHandler->getParameter('is_user_admin_code_unique')) {
            $tmpUser = $this->om->getRepository('ClarolineCoreBundle:User')->findOneByAdministrativeCode($code);
            if ($tmpUser && $tmpUser->getUsername() !== $user->getUsername()) {
                $this->context->addViolationAt(
                    'administrativeCode',
                    $this->translator->trans($constraint->error, ['%code%' => $code], 'platform')
                );
            }
        }
    }
public function validate($user, Constraint $constraint)
    {
        $code = $user->getAdministrativeCode();
        if (!empty($code) && $this->platformConfigHandler->getParameter('is_user_admin_code_unique')) {
            $tmpUser = $this->om->getRepository('ClarolineCoreBundle:User')->findOneByAdministrativeCode($code);
            if ($tmpUser && $tmpUser->getUsername() !== $user->getUsername()) {
                $this->context->addViolationAt(
                    'administrativeCode',
                    $this->translator->trans($constraint->error, ['%code%' => $code], 'platform')
                );
            }
        }
    }
public function validate ( $ user , Constraint $ constraint ) { $ code = $ user -> getAdministrativeCode ( ) ; if ( ! empty ( $ code ) && $ this -> platformConfigHandler -> getParameter ( 'is_user_admin_code_unique' ) ) { $ tmpUser = $ this -> om -> getRepository ( 'ClarolineCoreBundle:User' ) -> findOneByAdministrativeCode ( $ code ) ; if ( $ tmpUser && $ tmpUser -> getUsername ( ) !== $ user -> getUsername ( ) ) { $ this -> context -> addViolationAt ( 'administrativeCode' , $ this -> translator -> trans ( $ constraint -> error , [ '%code%' => $ code ] , 'platform' ) ) ; } } }
Checks if administration code is unique.

@param User       $user
@param Constraint $constraint
Checks if administration code is unique .