Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
helpdesk_gitlab
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
helpdesk_gitlab
Commits
e53adba8
Commit
e53adba8
authored
11 months ago
by
Daniel Speicher
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3442076
: Implement interfaces of framework
parent
51933657
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Pipeline
#156615
failed
11 months ago
Stage: build
Stage: validate
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/HelpdeskIntegration/GitLab.php
+34
-1
34 additions, 1 deletion
src/Plugin/HelpdeskIntegration/GitLab.php
with
34 additions
and
1 deletion
src/Plugin/HelpdeskIntegration/GitLab.php
+
34
−
1
View file @
e53adba8
...
...
@@ -8,6 +8,7 @@ use Drupal\helpdesk_integration\HelpdeskInterface;
use
Drupal\helpdesk_integration
\IssueInterface
;
use
Drupal\helpdesk_integration
\PluginBase
;
use
Drupal\user\UserInterface
;
use
Gitlab\Client
;
/**
* Plugin implementation of the GitLab.
...
...
@@ -22,6 +23,13 @@ class GitLab extends PluginBase {
use
StringTranslationTrait
;
/**
* The GitLab client.
*
* @var \Gitlab\Client|null
*/
protected
?Client
$client
=
NULL
;
/**
* {@inheritdoc}
*/
...
...
@@ -46,6 +54,7 @@ class GitLab extends PluginBase {
$form
[
'api_token'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'API Token'
),
'#default_value'
=>
$helpdesk
->
get
(
'api_token'
),
]
+
$required
;
$form
[
'project_id'
]
=
[
'#type'
=>
'textfield'
,
...
...
@@ -55,6 +64,7 @@ class GitLab extends PluginBase {
$form
[
'max_file_size'
]
=
[
'#type'
=>
'number'
,
'#title'
=>
$this
->
t
(
'Max. file size for attachments (in MB)'
),
'#default_value'
=>
$helpdesk
->
get
(
'max_file_size'
),
'#min'
=>
1
,
]
+
$required
;
...
...
@@ -79,7 +89,12 @@ class GitLab extends PluginBase {
* {@inheritdoc}
*/
public
function
createIssue
(
HelpdeskInterface
$helpdesk
,
IssueInterface
$issue
):
void
{
// @todo Implement createIssue() method.
$incident
=
$this
->
getClient
(
$helpdesk
)
->
issues
()
->
create
(
$helpdesk
->
get
(
'project_id'
),
[
'type'
=>
'INCIDENT'
,
'title'
=>
$issue
->
getTitle
(),
'description'
=>
$issue
->
get
(
'body'
)
->
value
,
]);
}
/**
...
...
@@ -103,4 +118,22 @@ class GitLab extends PluginBase {
return
FALSE
;
}
/**
* Gets the GitLAb client and initializes if necessary.
*
* @param \Drupal\helpdesk_integration\HelpdeskInterface $helpdesk
* The helpdesk.
*
* @return \Gitlab\Client
* The GitLab client.
*/
private
function
getClient
(
HelpdeskInterface
$helpdesk
):
Client
{
if
(
!
$this
->
client
)
{
$this
->
client
=
new
Client
();
$this
->
client
->
setUrl
(
$helpdesk
->
get
(
'url'
));
$this
->
client
->
authenticate
(
$helpdesk
->
get
(
'api_token'
),
Client
::
AUTH_HTTP_TOKEN
);
}
return
$this
->
client
;
}
}
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