public function UserManager::updateToken in Social Post 8.2
Same name and namespace in other branches
- 3.x src/User/UserManager.php \Drupal\social_post\User\UserManager::updateToken()
Update token of a particular record.
Parameters
string $plugin_id: Type of social network.
string $provider_user_id: Unique Social ID returned by social network.
string $token: Token provided by social_network.
Return value
bool True if updated False otherwise
File
- src/
User/ UserManager.php, line 152
Class
- UserManager
- Manages database related tasks.
Namespace
Drupal\social_post\UserCode
public function updateToken($plugin_id, $provider_user_id, $token) {
/** @var \Drupal\social_post\Entity\SocialPost|false $social_post_user */
$social_post_user = current($this->entityTypeManager
->getStorage($this->entityType)
->loadByProperties([
'plugin_id' => $plugin_id,
'provider_user_id' => $provider_user_id,
]));
if ($social_post_user === FALSE) {
return FALSE;
}
try {
$social_post_user
->setToken($token)
->save();
return TRUE;
} catch (EntityStorageException $e) {
$this->loggerFactory
->get($this
->getPluginId())
->error('Failed to save user with updated token. Error @error', [
'@error' => $e
->getMessage(),
]);
return FALSE;
}
}