Skip to content
Snippets Groups Projects
Commit 0cd82d19 authored by Eirik Morland's avatar Eirik Morland
Browse files

Issue #3417432 by eiriksm: Make sure ::setVcsConnection always saves a token and not string

parent b725d20e
No related branches found
No related tags found
1 merge request!27Convert in setter. Type hint in getter
Pipeline #83209 passed
......@@ -5,6 +5,7 @@ namespace Drupal\violinist_teams;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\State\State;
use Drupal\user\UserInterface;
use League\OAuth2\Client\Token\AccessToken;
/**
* Service for all things with managing teams I guess?
......@@ -130,12 +131,22 @@ class TeamManager {
*/
public function setVcsConnection(TeamNode $node, string $provider_id, $token) {
$connections = $this->getVcsConnections($node);
// Let's support passing a string here. Not ideal, but it will probably work
// at least.
if (is_string($token)) {
$token = new AccessToken([
'access_token' => $token,
]);
}
$connections[$provider_id] = $token;
$this->state->set(self::getVcsProviderStateKey($node), $connections);
}
/**
* Get all of the connections stored on a team.
*
* @return \League\OAuth2\Client\Token\AccessToken[]
* An array of access tokens, at least hopefully.
*/
public function getVcsConnections(TeamNode $node) : array {
return $this->state->get(self::getVcsProviderStateKey($node), []);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment