7
7
* For the full copyright and license information, please view the LICENSE
8
8
* file that was distributed with this source code.
9
9
*/
10
+
10
11
namespace VersionControl \GitlabIssueBundle \Controller ;
11
12
12
13
use Symfony \Component \HttpFoundation \Request ;
15
16
use Sensio \Bundle \FrameworkExtraBundle \Configuration \Route ;
16
17
use Sensio \Bundle \FrameworkExtraBundle \Configuration \Template ;
17
18
use VersionControl \GitControlBundle \Entity \ProjectIssueIntegrator ;
18
-
19
-
20
19
use VersionControl \GitlabIssueBundle \Entity \ProjectIssueIntegratorGitlab ;
21
20
use VersionControl \GitlabIssueBundle \Form \ProjectIssueIntegratorGitlabType ;
22
21
use VersionControl \GitlabIssueBundle \Form \ProjectIssueIntegratorGitlabNewType ;
23
22
use VersionControl \GitControlBundle \Annotation \ProjectAccess ;
24
-
25
23
use Symfony \Component \Form \Extension \Core \Type \SubmitType ;
26
24
27
25
/**
28
26
* Project controller.
29
27
*
30
28
* @Route("/project/{id}/issue-integrator/gitlab")
31
29
*/
32
- class ProjectIssueIntegratorGitlabController extends BaseProjectController{
33
-
34
- /**
35
- * Allow access by ajax only request
36
- * @var boolean
30
+ class ProjectIssueIntegratorGitlabController extends BaseProjectController
31
+ {
32
+ /**
33
+ * Allow access by ajax only request.
34
+ *
35
+ * @var bool
37
36
*/
38
37
protected $ ajaxOnly = false ;
39
-
40
- /**
38
+
39
+ /**
41
40
* Creates a new ProjectIssueIntegrator entity.
42
41
*
43
42
* @Route("/", name="project_issue_integrator_gitlab_create")
44
43
* @Method("POST")
45
44
* @Template("VersionControlGitlabIssueBundle:ProjectIssueIntegrator:new.html.twig")
46
45
* @ProjectAccess(grantType="OWNER")
47
46
*/
48
- public function createAction (Request $ request ,$ id )
47
+ public function createAction (Request $ request , $ id )
49
48
{
50
-
51
49
$ issueIntegrator = new ProjectIssueIntegratorGitlab ();
52
50
$ form = $ this ->createCreateForm ($ issueIntegrator );
53
51
$ form ->handleRequest ($ request );
54
52
55
53
if ($ form ->isValid ()) {
56
-
57
54
$ issueIntegrator ->setRepoType ('Gitlab ' );
58
55
$ issueIntegrator ->setProject ($ this ->project );
59
-
56
+
60
57
$ em = $ this ->getDoctrine ()->getManager ();
61
58
$ em ->persist ($ issueIntegrator );
62
59
$ em ->flush ();
63
-
60
+
64
61
$ this ->get ('session ' )->getFlashBag ()->add ('notice ' , 'Issue Integrator Record has been created ' );
65
62
66
- return $ this ->redirect ($ this ->generateUrl ('project_issue_integrator_gitlab_edit ' , array ('id ' => $ this ->project ->getId (), 'integratorId ' => $ issueIntegrator ->getId ())));
63
+ return $ this ->redirect ($ this ->generateUrl ('project_issue_integrator_gitlab_edit ' , array ('id ' => $ this ->project ->getId (), 'integratorId ' => $ issueIntegrator ->getId ())));
67
64
}
68
65
69
66
return array_merge ($ this ->viewVariables , array (
70
67
'entity ' => $ issueIntegrator ,
71
- 'form ' => $ form ->createView (),
68
+ 'form ' => $ form ->createView (),
72
69
));
73
70
}
74
71
@@ -101,20 +98,16 @@ private function createCreateForm(ProjectIssueIntegrator $issueIntegrator)
101
98
*/
102
99
public function newAction ($ id )
103
100
{
104
-
105
-
106
101
$ issueIntegrator = new ProjectIssueIntegratorGitlab ();
107
102
$ issueIntegrator ->setProject ($ this ->project );
108
- $ form = $ this ->createCreateForm ($ issueIntegrator );
103
+ $ form = $ this ->createCreateForm ($ issueIntegrator );
109
104
110
105
return array_merge ($ this ->viewVariables , array (
111
106
'entity ' => $ issueIntegrator ,
112
- 'form ' => $ form ->createView (),
107
+ 'form ' => $ form ->createView (),
113
108
));
114
109
}
115
110
116
-
117
-
118
111
/**
119
112
* Displays a form to edit an existing ProjectIssueIntegrator entity.
120
113
*
@@ -123,10 +116,8 @@ public function newAction($id)
123
116
* @Template()
124
117
* @ProjectAccess(grantType="OWNER")
125
118
*/
126
- public function editAction ($ id ,$ integratorId )
119
+ public function editAction ($ id , $ integratorId )
127
120
{
128
-
129
-
130
121
$ em = $ this ->getDoctrine ()->getManager ();
131
122
132
123
$ issueIntegrator = $ em ->getRepository ('VersionControlGitControlBundle:ProjectIssueIntegrator ' )->find ($ integratorId );
@@ -139,24 +130,24 @@ public function editAction($id,$integratorId)
139
130
$ deleteForm = $ this ->createDeleteForm ($ integratorId );
140
131
141
132
return array_merge ($ this ->viewVariables , array (
142
- 'entity ' => $ issueIntegrator ,
143
- 'edit_form ' => $ editForm ->createView (),
133
+ 'entity ' => $ issueIntegrator ,
134
+ 'edit_form ' => $ editForm ->createView (),
144
135
'delete_form ' => $ deleteForm ->createView (),
145
-
136
+
146
137
));
147
138
}
148
139
149
140
/**
150
- * Creates a form to edit a ProjectIssueIntegrator entity.
151
- *
152
- * @param ProjectIssueIntegrator $issueIntegrator The entity
153
- *
154
- * @return \Symfony\Component\Form\Form The form
155
- */
141
+ * Creates a form to edit a ProjectIssueIntegrator entity.
142
+ *
143
+ * @param ProjectIssueIntegrator $issueIntegrator The entity
144
+ *
145
+ * @return \Symfony\Component\Form\Form The form
146
+ */
156
147
private function createEditForm (ProjectIssueIntegrator $ issueIntegrator )
157
148
{
158
149
$ form = $ this ->createForm (ProjectIssueIntegratorGitlabType::class, $ issueIntegrator , array (
159
- 'action ' => $ this ->generateUrl ('project_issue_integrator_gitlab_update ' , array ('integratorId ' => $ issueIntegrator ->getId (),'id ' => $ this ->project ->getId ())),
150
+ 'action ' => $ this ->generateUrl ('project_issue_integrator_gitlab_update ' , array ('integratorId ' => $ issueIntegrator ->getId (), 'id ' => $ this ->project ->getId ())),
160
151
'method ' => 'PUT ' ,
161
152
));
162
153
@@ -172,40 +163,38 @@ private function createEditForm(ProjectIssueIntegrator $issueIntegrator)
172
163
* @Template("VersionControlGitlabIssueBundle:ProjectIssueIntegrator:edit.html.twig")
173
164
* @ProjectAccess(grantType="OWNER")
174
165
*/
175
- public function updateAction (Request $ request ,$ integratorId , $ id )
166
+ public function updateAction (Request $ request , $ integratorId , $ id )
176
167
{
177
-
178
-
179
168
$ em = $ this ->getDoctrine ()->getManager ();
180
169
181
170
$ issueIntegrator = $ em ->getRepository ('VersionControlGitControlBundle:ProjectIssueIntegrator ' )->find ($ integratorId );
182
171
183
172
if (!$ issueIntegrator ) {
184
173
throw $ this ->createNotFoundException ('Unable to find ProjectIssueIntegrator entity. ' );
185
174
}
186
-
175
+
187
176
$ project = $ issueIntegrator ->getProject ();
188
- $ this ->checkProjectAuthorization ($ project ,'OWNER ' );
177
+ $ this ->checkProjectAuthorization ($ project , 'OWNER ' );
189
178
190
179
$ deleteForm = $ this ->createDeleteForm ($ integratorId );
191
180
$ editForm = $ this ->createEditForm ($ issueIntegrator );
192
181
$ editForm ->handleRequest ($ request );
193
182
194
183
if ($ editForm ->isValid ()) {
195
184
$ em ->flush ();
196
-
185
+
197
186
$ this ->get ('session ' )->getFlashBag ()->add ('notice ' , 'Issue Integrator Record has been update ' );
198
187
199
- return $ this ->redirect ($ this ->generateUrl ('project_issue_integrator_gitlab_edit ' , array ('id ' => $ id ,'integratorId ' => $ integratorId )));
188
+ return $ this ->redirect ($ this ->generateUrl ('project_issue_integrator_gitlab_edit ' , array ('id ' => $ id , 'integratorId ' => $ integratorId )));
200
189
}
201
190
202
191
return array_merge ($ this ->viewVariables , array (
203
- 'entity ' => $ issueIntegrator ,
204
- 'edit_form ' => $ editForm ->createView (),
192
+ 'entity ' => $ issueIntegrator ,
193
+ 'edit_form ' => $ editForm ->createView (),
205
194
'delete_form ' => $ deleteForm ->createView (),
206
195
));
207
196
}
208
-
197
+
209
198
/**
210
199
* Creates a form to delete a ProjectIssueIntegrator entity by id.
211
200
*
@@ -222,5 +211,4 @@ private function createDeleteForm($integratorId)
222
211
->getForm ()
223
212
;
224
213
}
225
-
226
214
}
0 commit comments