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

Issue #3356365 by eiriksm: Make it possible to get VCS provider connections for team

parent f2b26644
No related branches found
No related tags found
1 merge request!11Issue #3356365: Make it possible to get VCS provider connections for team
......@@ -3,6 +3,7 @@
namespace Drupal\violinist_teams;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\State\State;
use Drupal\user\UserInterface;
/**
......@@ -17,14 +18,24 @@ class TeamManager {
*/
protected $entityTypeManager;
/**
* State service.
*
* @var \Drupal\Core\State\State
*/
protected $state;
/**
* Constructs a TeamManager object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\State\State $state
* The state service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
public function __construct(EntityTypeManagerInterface $entity_type_manager, State $state) {
$this->entityTypeManager = $entity_type_manager;
$this->state = $state;
}
/**
......@@ -83,4 +94,29 @@ class TeamManager {
}
}
/**
* Get a specific VCS provider connection.
*/
public function getVcsConnection(TeamNode $node, string $provider_id) {
$connections = $this->getVcsConnections($node);
if (empty($connections[$provider_id])) {
return FALSE;
}
return $connections[$provider_id];
}
/**
* Get all of the connections stored on a team.
*/
public function getVcsConnections(TeamNode $node) : array {
return $this->state->get(self::getVcsProviderStateKey($node), []);
}
/**
* Get the state key we use to store connections for it.
*/
public static function getVcsProviderStateKey(TeamNode $node) : string {
return sprintf('violinist_teams:vcs_providers:%s', $node->uuid());
}
}
services:
violinist_teams.team_manager:
class: Drupal\violinist_teams\TeamManager
arguments: ['@entity_type.manager']
arguments:
- '@entity_type.manager'
- '@state'
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