public function setUsername(string $username): void
	{
		if (Strings::match($username, '/[^A-Za-z0-9_]/')) {
			throw new InvalidArgumentException('Username contains invalid characters');
		}

		/* @var $repository UsersRepository */
		$repository = $this->getRepository();
		$user = $repository->getByUsername($username);
		if ($user !== null && $user !== $this) {
			throw new UniqueConstraintViolationException("Username '$username' exists");
		}
		$this->username = $username;
	}
public function setUsername(string $username): void
	{
		if (Strings::match($username, '/[^A-Za-z0-9_]/')) {
			throw new InvalidArgumentException('Username contains invalid characters');
		}

		/* @var $repository UsersRepository */
		$repository = $this->getRepository();
		$user = $repository->getByUsername($username);
		if ($user !== null && $user !== $this) {
			throw new UniqueConstraintViolationException("Username '$username' exists");
		}
		$this->username = $username;
	}
public function setUsername ( string $ username ) : void { if ( Strings :: match ( $ username , '/[^A-Za-z0-9_]/' ) ) { throw new InvalidArgumentException ( 'Username contains invalid characters' ) ; } /* @var $repository UsersRepository */ $ repository = $ this -> getRepository ( ) ; $ user = $ repository -> getByUsername ( $ username ) ; if ( $ user !== null && $ user !== $ this ) { throw new UniqueConstraintViolationException ( "Username '$username' exists" ) ; } $ this -> username = $ username ; }
Ulozi uzivatelske jmeno
@param string $username
@throws UniqueConstraintViolationException
@throws InvalidArgumentException
Ulozi uzivatelske jmeno