setEntity(GithubUser::class); $metadata->setConnectionName('main'); $metadata->setDatabase($options['database']); $metadata->setTable('afup_user_github'); $metadata ->addField([ 'columnName' => 'id', 'fieldName' => 'id', 'primary' => true, 'autoincrement' => true, 'type' => 'int' ]) ->addField([ 'columnName' => 'github_id', 'fieldName' => 'githubId', 'type' => 'int' ]) ->addField([ 'columnName' => 'login', 'fieldName' => 'login', 'type' => 'string' ]) ->addField([ 'columnName' => 'name', 'fieldName' => 'name', 'type' => 'string' ]) ->addField([ 'columnName' => 'company', 'fieldName' => 'company', 'type' => 'string' ]) ->addField([ 'columnName' => 'profile_url', 'fieldName' => 'profileUrl', 'type' => 'string' ]) ->addField([ 'columnName' => 'avatar_url', 'fieldName' => 'avatarUrl', 'type' => 'string' ]) ->addField([ 'columnName' => 'afup_crew', 'fieldName' => 'afupCrew', 'type' => 'bool', 'serializer' => Boolean::class ]) ; return $metadata; } /** * @inheritDoc */ public function loadUserByUsername($username) { $user = $this->getOneBy(['login' => $username]); if ($user === null) { throw new UsernameNotFoundException(); } return $user; } /** * @inheritDoc */ public function refreshUser(UserInterface $user) { if (($user instanceof GithubUser) === false) { throw new UnsupportedUserException(); } /** * @var GithubUser $user */ $newUser = $this->getOneBy(['id' => $user->getId()]); return $newUser; } /** * @inheritDoc */ public function supportsClass($class) { return ($class === GithubUser::class); } }