Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
violinist_teams
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
violinist_teams
Commits
d4dc1ca8
Commit
d4dc1ca8
authored
1 year ago
by
Eirik Morland
Browse files
Options
Downloads
Patches
Plain Diff
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
!11
Issue #3356365: Make it possible to get VCS provider connections for team
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TeamManager.php
+37
-1
37 additions, 1 deletion
src/TeamManager.php
violinist_teams.services.yml
+3
-1
3 additions, 1 deletion
violinist_teams.services.yml
with
40 additions
and
2 deletions
src/TeamManager.php
+
37
−
1
View file @
d4dc1ca8
...
...
@@ -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
());
}
}
This diff is collapsed.
Click to expand it.
violinist_teams.services.yml
+
3
−
1
View file @
d4dc1ca8
services
:
violinist_teams.team_manager
:
class
:
Drupal\violinist_teams\TeamManager
arguments
:
[
'
@entity_type.manager'
]
arguments
:
-
'
@entity_type.manager'
-
'
@state'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment