Skip to content

Commit 773db72

Browse files
bobfloatsroot
authored and
root
committed
Run php-cs-fixer on GitlabIssueBundle
1 parent 43448ab commit 773db72

32 files changed

+811
-793
lines changed

src/VersionControl/GitlabIssueBundle/Controller/ProjectIssueIntegratorGitlabController.php

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10+
1011
namespace VersionControl\GitlabIssueBundle\Controller;
1112

1213
use Symfony\Component\HttpFoundation\Request;
@@ -15,60 +16,56 @@
1516
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
1617
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
1718
use VersionControl\GitControlBundle\Entity\ProjectIssueIntegrator;
18-
19-
2019
use VersionControl\GitlabIssueBundle\Entity\ProjectIssueIntegratorGitlab;
2120
use VersionControl\GitlabIssueBundle\Form\ProjectIssueIntegratorGitlabType;
2221
use VersionControl\GitlabIssueBundle\Form\ProjectIssueIntegratorGitlabNewType;
2322
use VersionControl\GitControlBundle\Annotation\ProjectAccess;
24-
2523
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
2624

2725
/**
2826
* Project controller.
2927
*
3028
* @Route("/project/{id}/issue-integrator/gitlab")
3129
*/
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
3736
*/
3837
protected $ajaxOnly = false;
39-
40-
/**
38+
39+
/**
4140
* Creates a new ProjectIssueIntegrator entity.
4241
*
4342
* @Route("/", name="project_issue_integrator_gitlab_create")
4443
* @Method("POST")
4544
* @Template("VersionControlGitlabIssueBundle:ProjectIssueIntegrator:new.html.twig")
4645
* @ProjectAccess(grantType="OWNER")
4746
*/
48-
public function createAction(Request $request,$id)
47+
public function createAction(Request $request, $id)
4948
{
50-
5149
$issueIntegrator = new ProjectIssueIntegratorGitlab();
5250
$form = $this->createCreateForm($issueIntegrator);
5351
$form->handleRequest($request);
5452

5553
if ($form->isValid()) {
56-
5754
$issueIntegrator->setRepoType('Gitlab');
5855
$issueIntegrator->setProject($this->project);
59-
56+
6057
$em = $this->getDoctrine()->getManager();
6158
$em->persist($issueIntegrator);
6259
$em->flush();
63-
60+
6461
$this->get('session')->getFlashBag()->add('notice', 'Issue Integrator Record has been created');
6562

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())));
6764
}
6865

6966
return array_merge($this->viewVariables, array(
7067
'entity' => $issueIntegrator,
71-
'form' => $form->createView(),
68+
'form' => $form->createView(),
7269
));
7370
}
7471

@@ -101,20 +98,16 @@ private function createCreateForm(ProjectIssueIntegrator $issueIntegrator)
10198
*/
10299
public function newAction($id)
103100
{
104-
105-
106101
$issueIntegrator = new ProjectIssueIntegratorGitlab();
107102
$issueIntegrator->setProject($this->project);
108-
$form = $this->createCreateForm($issueIntegrator);
103+
$form = $this->createCreateForm($issueIntegrator);
109104

110105
return array_merge($this->viewVariables, array(
111106
'entity' => $issueIntegrator,
112-
'form' => $form->createView(),
107+
'form' => $form->createView(),
113108
));
114109
}
115110

116-
117-
118111
/**
119112
* Displays a form to edit an existing ProjectIssueIntegrator entity.
120113
*
@@ -123,10 +116,8 @@ public function newAction($id)
123116
* @Template()
124117
* @ProjectAccess(grantType="OWNER")
125118
*/
126-
public function editAction($id,$integratorId)
119+
public function editAction($id, $integratorId)
127120
{
128-
129-
130121
$em = $this->getDoctrine()->getManager();
131122

132123
$issueIntegrator = $em->getRepository('VersionControlGitControlBundle:ProjectIssueIntegrator')->find($integratorId);
@@ -139,24 +130,24 @@ public function editAction($id,$integratorId)
139130
$deleteForm = $this->createDeleteForm($integratorId);
140131

141132
return array_merge($this->viewVariables, array(
142-
'entity' => $issueIntegrator,
143-
'edit_form' => $editForm->createView(),
133+
'entity' => $issueIntegrator,
134+
'edit_form' => $editForm->createView(),
144135
'delete_form' => $deleteForm->createView(),
145-
136+
146137
));
147138
}
148139

149140
/**
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+
*/
156147
private function createEditForm(ProjectIssueIntegrator $issueIntegrator)
157148
{
158149
$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())),
160151
'method' => 'PUT',
161152
));
162153

@@ -172,40 +163,38 @@ private function createEditForm(ProjectIssueIntegrator $issueIntegrator)
172163
* @Template("VersionControlGitlabIssueBundle:ProjectIssueIntegrator:edit.html.twig")
173164
* @ProjectAccess(grantType="OWNER")
174165
*/
175-
public function updateAction(Request $request,$integratorId, $id)
166+
public function updateAction(Request $request, $integratorId, $id)
176167
{
177-
178-
179168
$em = $this->getDoctrine()->getManager();
180169

181170
$issueIntegrator = $em->getRepository('VersionControlGitControlBundle:ProjectIssueIntegrator')->find($integratorId);
182171

183172
if (!$issueIntegrator) {
184173
throw $this->createNotFoundException('Unable to find ProjectIssueIntegrator entity.');
185174
}
186-
175+
187176
$project = $issueIntegrator->getProject();
188-
$this->checkProjectAuthorization($project,'OWNER');
177+
$this->checkProjectAuthorization($project, 'OWNER');
189178

190179
$deleteForm = $this->createDeleteForm($integratorId);
191180
$editForm = $this->createEditForm($issueIntegrator);
192181
$editForm->handleRequest($request);
193182

194183
if ($editForm->isValid()) {
195184
$em->flush();
196-
185+
197186
$this->get('session')->getFlashBag()->add('notice', 'Issue Integrator Record has been update');
198187

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)));
200189
}
201190

202191
return array_merge($this->viewVariables, array(
203-
'entity' => $issueIntegrator,
204-
'edit_form' => $editForm->createView(),
192+
'entity' => $issueIntegrator,
193+
'edit_form' => $editForm->createView(),
205194
'delete_form' => $deleteForm->createView(),
206195
));
207196
}
208-
197+
209198
/**
210199
* Creates a form to delete a ProjectIssueIntegrator entity by id.
211200
*
@@ -222,5 +211,4 @@ private function createDeleteForm($integratorId)
222211
->getForm()
223212
;
224213
}
225-
226214
}

src/VersionControl/GitlabIssueBundle/DataTransformer/DataTransformerInterface.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10+
1011
namespace VersionControl\GitlabIssueBundle\DataTransformer;
1112

12-
interface DataTransformerInterface{
13-
14-
public function transform($array);
15-
16-
public function reverseTransform($entiy);
17-
18-
}
13+
interface DataTransformerInterface
14+
{
15+
public function transform($array);
16+
17+
public function reverseTransform($entiy);
18+
}

src/VersionControl/GitlabIssueBundle/DataTransformer/GitlabProjectToEntityTransformer.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10+
1011
namespace VersionControl\GitlabIssueBundle\DataTransformer;
1112

12-
use VersionControl\GitlabIssueBundle\DataTransformer\DataTransformerInterface;
1313
use VersionControl\GitlabIssueBundle\Entity\GitlabProject;
1414
use Symfony\Component\Form\Exception\TransformationFailedException;
1515

1616
class GitlabProjectToEntityTransformer implements DataTransformerInterface
1717
{
18-
19-
2018
/**
2119
* Transforms an issue array into an issue Entity object.
2220
*
23-
* @param array $gitLabProject
21+
* @param array $gitLabProject
22+
*
2423
* @return \VersionControl\GitlabIssueBundle\Entity\GitlabProject|null
2524
*/
2625
public function transform($gitLabProject)
2726
{
2827
if (null === $gitLabProject) {
2928
return null;
3029
}
31-
30+
3231
$gitLabProjectEntity = new GitlabProject();
3332
$gitLabProjectEntity->setId($gitLabProject['id']);
3433
$gitLabProjectEntity->setName($gitLabProject['name']);
@@ -39,17 +38,19 @@ public function transform($gitLabProject)
3938
/**
4039
* Transforms a string (number) to an object (issue).
4140
*
42-
* @param VersionControl\GitlabIssueBundle\Entity\Issues\GitlabProject $gitLabProject
41+
* @param VersionControl\GitlabIssueBundle\Entity\Issues\GitlabProject $gitLabProject
42+
*
4343
* @return string|null label name
44-
* @throws TransformationFailedException if object (issue) is not found.
44+
*
45+
* @throws TransformationFailedException if object (issue) is not found
4546
*/
4647
public function reverseTransform($gitLabProjectEntity)
4748
{
4849
if ($gitLabProjectEntity === null) {
4950
// causes a validation error
5051
throw new TransformationFailedException('userEntity is null');
5152
}
52-
53+
5354
return $gitLabProjectEntity->getName();
5455
}
55-
}
56+
}

src/VersionControl/GitlabIssueBundle/DataTransformer/IssueCommentToEntityTransformer.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,77 +7,81 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10+
1011
namespace VersionControl\GitlabIssueBundle\DataTransformer;
1112

12-
use VersionControl\GitlabIssueBundle\DataTransformer\DataTransformerInterface;
1313
use VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment;
1414
use Symfony\Component\Form\Exception\TransformationFailedException;
1515

1616
class IssueCommentToEntityTransformer implements DataTransformerInterface
1717
{
18-
1918
private $userTransformer;
2019

2120
public function __construct()
2221
{
2322
$this->userTransformer = new UserToEntityTransformer();
2423
}
25-
24+
2625
/**
2726
* Transforms an issue array into an issue Entity object.
2827
*
29-
* @param \VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment|null $issueComment
28+
* @param \VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment|null $issueComment
29+
*
3030
* @return string
3131
*/
3232
public function transform($issueComment)
3333
{
3434
if (null === $issueComment) {
3535
return null;
3636
}
37-
37+
3838
$issueCommentEntity = new IssueComment();
3939
$issueCommentEntity->setId($issueComment['id']);
4040
$issueCommentEntity->setComment($issueComment['body']);
4141
$issueCommentEntity->setCreatedAt($this->formatDate($issueComment['created_at']));
42-
if(isset($issueComment['updated_at'])){
42+
if (isset($issueComment['updated_at'])) {
4343
$issueCommentEntity->setUpdatedAt($this->formatDate($issueComment['updated_at']));
4444
}
4545

46-
if(isset($issueComment['author']) && is_array($issueComment['author'])){
46+
if (isset($issueComment['author']) && is_array($issueComment['author'])) {
4747
$user = $this->userTransformer->transform($issueComment['author']);
4848
$issueCommentEntity->setUser($user);
4949
}
50-
50+
5151
return $issueCommentEntity;
5252
}
5353

5454
/**
5555
* Transforms a string (number) to an object (issue).
5656
*
57-
* @param VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment $issueCommentEntity
57+
* @param VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment $issueCommentEntity
58+
*
5859
* @return array|null
59-
* @throws TransformationFailedException if object (issue) is not found.
60+
*
61+
* @throws TransformationFailedException if object (issue) is not found
6062
*/
6163
public function reverseTransform($issueCommentEntity)
6264
{
6365
if ($issueCommentEntity === null) {
6466
// causes a validation error
6567
throw new TransformationFailedException('issueCommentEntity is null');
6668
}
67-
69+
6870
$issueComment = array(
69-
'body' => $issueCommentEntity->getComment()
71+
'body' => $issueCommentEntity->getComment(),
7072
);
71-
73+
7274
return $issueComment;
7375
}
74-
75-
protected function formatDate($date){
76+
77+
protected function formatDate($date)
78+
{
7679
try {
7780
$dateTime = new \DateTime($date);
7881
} catch (Exception $e) {
7982
echo $e->getMessage();
8083
}
84+
8185
return $dateTime;
8286
}
83-
}
87+
}

0 commit comments

Comments
 (0)