/** * Query to update a user profile. * * @param string $guid * @param string $provider * @param string $resourceOwnerId * @param ResourceOwnerInterface $resourceOwner * * @return \Doctrine\DBAL\Query\QueryBuilder */ public function queryUpdate($guid, $provider, $resourceOwnerId, ResourceOwnerInterface $resourceOwner) { $query = $this->getQueryBuilder()->update($this->tableNameProvider)->set('lastupdate', ':lastupdate')->set('resource_owner', ':resource_owner')->where('provider = :provider')->andWhere('resource_owner_id = :resource_owner_id')->setParameters(['provider' => $provider, 'resource_owner_id' => $resourceOwnerId, 'lastupdate' => date('Y-m-d H:i:s', time()), 'resource_owner' => json_encode($resourceOwner->toArray())]); if ($guid !== null) { $query->andWhere('resource_owner_id = :resource_owner_id')->setParameter('guid', ':guid'); } return $query; }
/** * {@inheritdoc} */ public function map(Member $member, ResourceOwnerInterface $resourceOwner) { $mapping = $this->getMapping(); $array = $resourceOwner->toArray(); foreach ($mapping as $target => $source) { if (method_exists($resourceOwner, "get{$source}")) { $method = "get{$source}"; $member->{$target} = $resourceOwner->{$method}(); } elseif (array_key_exists($source, $array)) { $member->{$target} = $array[$source]; } } return $member; }
/** * {@inheritdoc} */ protected function getSuggestions(ResourceOwnerInterface $resourceOwner) { return ['username' => $resourceOwner->getNickname(), 'avatarUrl' => array_get($resourceOwner->toArray(), 'avatar_url')]; }
protected function getSuggestions(ResourceOwnerInterface $resourceOwner) { return ['username' => $resourceOwner->toArray()['username'], 'email' => $resourceOwner->toArray()['email']]; }