Completed
Push — master ( 39dfcd...b9f790 )
by Aleksandar
27:20
created
src/Article/src/Controller/PostController.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
     public function index() : HtmlResponse
69 69
     {
70 70
         $params = $this->request->getQueryParams();
71
-        $page   = isset($params['page']) ? $params['page'] : 1;
72
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
71
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
72
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
73 73
         $posts  = $this->postService->fetchAllArticles($page, $limit);
74 74
 
75
-        return new HtmlResponse($this->template->render('article::post/index', ['list' => $posts, 'layout' => 'layout/admin']));
75
+        return new HtmlResponse($this->template->render('article::post/index', [ 'list' => $posts, 'layout' => 'layout/admin' ]));
76 76
     }
77 77
 
78 78
     /**
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return \Psr\Http\Message\ResponseInterface
82 82
      */
83
-    public function edit($errors = []) : \Psr\Http\Message\ResponseInterface
83
+    public function edit($errors = [ ]) : \Psr\Http\Message\ResponseInterface
84 84
     {
85 85
         $id         = $this->request->getAttribute('id');
86 86
         $post       = $this->postService->fetchSingleArticle($id);
87 87
         $categories = $this->categoryService->getAll();
88 88
 
89
-        if($this->request->getParsedBody()){
90
-            $post             = (object)($this->request->getParsedBody() + (array)$post);
89
+        if ($this->request->getParsedBody()) {
90
+            $post             = (object) ($this->request->getParsedBody() + (array) $post);
91 91
             $post->article_id = $id;
92 92
         }
93 93
 
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function save() : \Psr\Http\Message\ResponseInterface
110 110
     {
111
-        try{
111
+        try {
112 112
             $id   = $this->request->getAttribute('id');
113 113
             $user = $this->session->getStorage()->user;
114 114
             $data = $this->request->getParsedBody();
115 115
             $data += (new Request())->getFiles()->toArray();
116 116
 
117
-            if($id){
117
+            if ($id) {
118 118
                 $this->postService->updateArticle($data, $id);
119 119
             }
120
-            else{
120
+            else {
121 121
                 $this->postService->createArticle($user, $data);
122 122
             }
123 123
         }
124
-        catch(FilterException $fe){
124
+        catch (FilterException $fe) {
125 125
             return $this->edit($fe->getArrayMessages());
126 126
         }
127
-        catch(\Exception $e){
127
+        catch (\Exception $e) {
128 128
             throw $e;
129 129
         }
130 130
 
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function delete() : \Psr\Http\Message\ResponseInterface
141 141
     {
142
-        try{
142
+        try {
143 143
             $this->postService->deleteArticle($this->request->getAttribute('id'));
144 144
         }
145
-        catch(\Exception $e){
145
+        catch (\Exception $e) {
146 146
             throw $e;
147 147
         }
148 148
 
149 149
         return $this->response->withStatus(302)->withHeader(
150
-            'Location', $this->router->generateUri('admin.posts', ['action' => 'index'])
150
+            'Location', $this->router->generateUri('admin.posts', [ 'action' => 'index' ])
151 151
         );
152 152
     }
153 153
 }
Please login to merge, or discard this patch.
src/Article/src/Controller/VideoController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Article\Controller;
6 6
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
     public function index(): HtmlResponse
69 69
     {
70 70
         $params = $this->request->getQueryParams();
71
-        $page   = isset($params['page']) ? $params['page'] : 1;
72
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
71
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
72
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
73 73
         $videos = $this->videoService->fetchAllArticles($page, $limit);
74 74
 
75
-        return new HtmlResponse($this->template->render('article::video/index', ['list' => $videos, 'layout' => 'layout/admin']));
75
+        return new HtmlResponse($this->template->render('article::video/index', [ 'list' => $videos, 'layout' => 'layout/admin' ]));
76 76
     }
77 77
 
78 78
     /**
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return \Psr\Http\Message\ResponseInterface
82 82
      */
83
-    public function edit($errors = []): \Psr\Http\Message\ResponseInterface
83
+    public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface
84 84
     {
85 85
         $id         = $this->request->getAttribute('id');
86 86
         $video      = $this->videoService->fetchSingleArticle($id);
87 87
         $categories = $this->categoryService->getAll();
88 88
 
89
-        if($this->request->getParsedBody()) {
90
-            $video             = (object)($this->request->getParsedBody() + (array)$video);
89
+        if ($this->request->getParsedBody()) {
90
+            $video             = (object) ($this->request->getParsedBody() + (array) $video);
91 91
             $video->article_id = $id;
92 92
         }
93 93
 
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
             $data = $this->request->getParsedBody();
115 115
             $data += (new Request())->getFiles()->toArray();
116 116
 
117
-            if($id) {
117
+            if ($id) {
118 118
                 $this->videoService->updateArticle($data, $id);
119 119
             } else {
120 120
                 $this->videoService->createArticle($user, $data);
121 121
             }
122 122
         }
123
-        catch(FilterException $fe) {
123
+        catch (FilterException $fe) {
124 124
             return $this->edit($fe->getArrayMessages());
125 125
         }
126
-        catch(\Exception $e) {
126
+        catch (\Exception $e) {
127 127
             throw $e;
128 128
         }
129 129
 
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
         try {
142 142
             $this->videoService->deleteArticle($this->request->getAttribute('id'));
143 143
         }
144
-        catch(\Exception $e) {
144
+        catch (\Exception $e) {
145 145
             throw $e;
146 146
         }
147 147
 
148 148
         return $this->response->withStatus(302)->withHeader(
149
-            'Location', $this->router->generateUri('admin.videos', ['action' => 'index'])
149
+            'Location', $this->router->generateUri('admin.videos', [ 'action' => 'index' ])
150 150
         );
151 151
     }
152 152
 }
Please login to merge, or discard this patch.
src/Article/src/Controller/EventController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Article\Controller;
6 6
 
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
     public function index(): \Psr\Http\Message\ResponseInterface
35 35
     {
36 36
         $params = $this->request->getQueryParams();
37
-        $page   = isset($params['page']) ? $params['page'] : 1;
38
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
37
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
38
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
39 39
         $events = $this->eventService->fetchAllArticles($page, $limit);
40 40
 
41
-        return new HtmlResponse($this->template->render('article::event/index', ['list' => $events, 'layout' => 'layout/admin']));
41
+        return new HtmlResponse($this->template->render('article::event/index', [ 'list' => $events, 'layout' => 'layout/admin' ]));
42 42
     }
43 43
 
44
-    public function edit($errors = []): \Psr\Http\Message\ResponseInterface
44
+    public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface
45 45
     {
46 46
         $id         = $this->request->getAttribute('id');
47 47
         $event      = $this->eventService->fetchSingleArticle($id);
48 48
         $categories = $this->categoryService->getAll();
49 49
 
50
-        if($this->request->getParsedBody()) {
51
-            $event             = (object)($this->request->getParsedBody() + (array)$event);
50
+        if ($this->request->getParsedBody()) {
51
+            $event             = (object) ($this->request->getParsedBody() + (array) $event);
52 52
             $event->article_id = $id;
53 53
         }
54 54
 
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
             $data = $this->request->getParsedBody();
69 69
             $data += (new Request())->getFiles()->toArray();
70 70
 
71
-            if($id) {
71
+            if ($id) {
72 72
                 $this->eventService->updateArticle($data, $id);
73 73
             } else {
74 74
                 $this->eventService->createArticle($user, $data);
75 75
             }
76 76
         }
77
-        catch(FilterException $fe) {
77
+        catch (FilterException $fe) {
78 78
             return $this->edit($fe->getArrayMessages());
79 79
         }
80
-        catch(\Exception $e) {
80
+        catch (\Exception $e) {
81 81
             throw $e;
82 82
         }
83 83
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         try {
90 90
             $this->eventService->deleteArticle($this->request->getAttribute('id'));
91 91
         }
92
-        catch(\Exception $e) {
92
+        catch (\Exception $e) {
93 93
             throw $e;
94 94
         }
95 95
 
Please login to merge, or discard this patch.
src/Article/src/Filter/EventFilter.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,67 +12,67 @@
 block discarded – undo
12 12
 
13 13
     public function getInputFilter()
14 14
     {
15
-        if(!$this->inputFilter){
15
+        if (!$this->inputFilter) {
16 16
             $inputFilter = new InputFilter();
17 17
 
18 18
             $inputFilter->add([
19 19
                 'name'       => 'title',
20 20
                 'required'   => true,
21
-                'filters'    => [['name' => 'StringTrim']],
21
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
22 22
                 'validators' => [
23
-                    ['name' => 'NotEmpty'],
24
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
23
+                    [ 'name' => 'NotEmpty' ],
24
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
25 25
                 ],
26 26
             ]);
27 27
 
28 28
             $inputFilter->add([
29 29
                 'name'     => 'sub_title',
30 30
                 'required' => false,
31
-                'filters'  => [['name' => 'StringTrim']]
31
+                'filters'  => [ [ 'name' => 'StringTrim' ] ]
32 32
             ]);
33 33
 
34 34
             $inputFilter->add([
35 35
                 'name'     => 'place_name',
36 36
                 'required' => true,
37
-                'filters'  => [['name' => 'StringTrim']]
37
+                'filters'  => [ [ 'name' => 'StringTrim' ] ]
38 38
             ]);
39 39
 
40 40
             $inputFilter->add([
41 41
                 'name'       => 'body',
42 42
                 'required'   => true,
43
-                'filters'    => [['name' => 'StringTrim']],
43
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
44 44
                 'validators' => [
45
-                    ['name' => 'NotEmpty'],
46
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 1500]],
45
+                    [ 'name' => 'NotEmpty' ],
46
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 1500 ] ],
47 47
                 ],
48 48
             ]);
49 49
 
50 50
             $inputFilter->add([
51 51
                 'name'       => 'start_at',
52 52
                 'required'   => true,
53
-                'filters'    => [['name' => 'StringTrim']],
54
-                'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]]
53
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
54
+                'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ]
55 55
             ]);
56 56
 
57 57
             $inputFilter->add([
58 58
                 'name'       => 'end_at',
59 59
                 'required'   => true,
60
-                'filters'    => [['name' => 'StringTrim']],
61
-                'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]]
60
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
61
+                'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ]
62 62
             ]);
63 63
 
64 64
             $inputFilter->add([
65 65
                 'name'       => 'longitude',
66 66
                 'required'   => true,
67
-                'filters'    => [['name' => 'StringTrim']],
68
-                'validators' => [['name' => 'NotEmpty']],
67
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
68
+                'validators' => [ [ 'name' => 'NotEmpty' ] ],
69 69
             ]);
70 70
 
71 71
             $inputFilter->add([
72 72
                 'name'       => 'latitude',
73 73
                 'required'   => true,
74
-                'filters'    => [['name' => 'StringTrim']],
75
-                'validators' => [['name' => 'NotEmpty']],
74
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
75
+                'validators' => [ [ 'name' => 'NotEmpty' ] ],
76 76
             ]);
77 77
 
78 78
             $this->inputFilter = $inputFilter;
Please login to merge, or discard this patch.
src/Article/src/Filter/DiscussionFilter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,26 +12,26 @@
 block discarded – undo
12 12
 
13 13
     public function getInputFilter()
14 14
     {
15
-        if(!$this->inputFilter){
15
+        if (!$this->inputFilter) {
16 16
             $inputFilter = new InputFilter();
17 17
 
18 18
             $inputFilter->add([
19 19
                 'name'       => 'title',
20 20
                 'required'   => true,
21
-                'filters'    => [['name' => 'StringTrim']],
21
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
22 22
                 'validators' => [
23
-                    ['name' => 'NotEmpty'],
24
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
23
+                    [ 'name' => 'NotEmpty' ],
24
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
25 25
                 ],
26 26
             ]);
27 27
 
28 28
             $inputFilter->add([
29 29
                 'name'       => 'body',
30 30
                 'required'   => true,
31
-                'filters'    => [['name' => 'StringTrim']],
31
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
32 32
                 'validators' => [
33
-                    ['name' => 'NotEmpty'],
34
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 1500]],
33
+                    [ 'name' => 'NotEmpty' ],
34
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 1500 ] ],
35 35
                 ],
36 36
             ]);
37 37
 
Please login to merge, or discard this patch.
src/Article/src/Filter/VideoFilter.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,46 +11,46 @@
 block discarded – undo
11 11
 
12 12
     public function getInputFilter()
13 13
     {
14
-        if(!$this->inputFilter){
14
+        if (!$this->inputFilter) {
15 15
             $inputFilter = new InputFilter();
16 16
 
17 17
             $inputFilter->add([
18 18
                 'name'       => 'title',
19 19
                 'required'   => true,
20
-                'filters'    => [['name' => 'StringTrim']],
20
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
21 21
                 'validators' => [
22
-                    ['name' => 'NotEmpty'],
23
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
22
+                    [ 'name' => 'NotEmpty' ],
23
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
24 24
                 ],
25 25
             ]);
26 26
 
27 27
             $inputFilter->add([
28 28
                 'name'       => 'body',
29 29
                 'required'   => true,
30
-                'filters'    => [['name' => 'StringTrim']],
30
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
31 31
                 'validators' => [
32
-                    ['name' => 'NotEmpty'],
33
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 5000]],
32
+                    [ 'name' => 'NotEmpty' ],
33
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 5000 ] ],
34 34
                 ],
35 35
             ]);
36 36
 
37 37
             $inputFilter->add([
38 38
                 'name'       => 'lead',
39 39
                 'required'   => true,
40
-                'filters'    => [['name' => 'StringTrim']],
40
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
41 41
                 'validators' => [
42
-                    ['name' => 'NotEmpty'],
43
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 50000]],
42
+                    [ 'name' => 'NotEmpty' ],
43
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 50000 ] ],
44 44
                 ],
45 45
             ]);
46 46
 
47 47
             $inputFilter->add([
48 48
                 'name'       => 'embed_code',
49 49
                 'required'   => true,
50
-                'filters'    => [['name' => 'StringTrim']],
50
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
51 51
                 'validators' => [
52
-                    ['name' => 'NotEmpty'],
53
-                    ['name' => 'StringLength', 'options' => ['min' => 100, 'max' => 5000]],
52
+                    [ 'name' => 'NotEmpty' ],
53
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 100, 'max' => 5000 ] ],
54 54
                 ],
55 55
             ]);
56 56
 
Please login to merge, or discard this patch.
src/Admin/src/ConfigProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
                     'admin/pagination' => __DIR__ . '/../templates/admin/partial/pagination.phtml',
14 14
                 ],
15 15
                 'paths' => [
16
-                    'admin' => [__DIR__ . '/../templates/admin'],
16
+                    'admin' => [ __DIR__ . '/../templates/admin' ],
17 17
                 ],
18 18
             ],
19 19
 
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
                     'name'            => 'auth',
31 31
                     'path'            => '/auth/:action',
32 32
                     'middleware'      => Controller\AuthController::class,
33
-                    'allowed_methods' => ['GET', 'POST'],
33
+                    'allowed_methods' => [ 'GET', 'POST' ],
34 34
                 ],
35 35
                 [
36 36
                     'name'            => 'admin',
37 37
                     'path'            => '/admin',
38 38
                     'middleware'      => Action\IndexAction::class,
39
-                    'allowed_methods' => ['GET'],
39
+                    'allowed_methods' => [ 'GET' ],
40 40
                 ],
41 41
                 [
42 42
                     'name'            => 'admin.users',
43 43
                     'path'            => '/admin/users',
44 44
                     'middleware'      => Controller\UserController::class,
45
-                    'allowed_methods' => ['GET']
45
+                    'allowed_methods' => [ 'GET' ]
46 46
                 ],
47 47
                 [
48 48
                     'name'            => 'admin.users.action',
49 49
                     'path'            => '/admin/users/:action/:id',
50 50
                     'middleware'      => Controller\UserController::class,
51
-                    'allowed_methods' => ['GET', 'POST']
51
+                    'allowed_methods' => [ 'GET', 'POST' ]
52 52
                 ],
53 53
             ],
54 54
         ];
Please login to merge, or discard this patch.
src/Article/src/Filter/PostFilter.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@
 block discarded – undo
12 12
 
13 13
     public function getInputFilter()
14 14
     {
15
-        if(!$this->inputFilter) {
15
+        if (!$this->inputFilter) {
16 16
             $inputFilter = new InputFilter();
17 17
 
18 18
             $inputFilter->add([
19 19
                 'name'       => 'title',
20 20
                 'required'   => true,
21
-                'filters'    => [['name' => 'StringTrim']],
21
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
22 22
                 'validators' => [
23
-                    ['name' => 'NotEmpty'],
24
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
23
+                    [ 'name' => 'NotEmpty' ],
24
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
25 25
                 ],
26 26
             ]);
27 27
 
28 28
             $inputFilter->add([
29 29
                 'name'       => 'body',
30 30
                 'required'   => true,
31
-                'filters'    => [['name' => 'StringTrim']],
31
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
32 32
                 'validators' => [
33
-                    ['name' => 'NotEmpty'],
34
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100000]],
33
+                    [ 'name' => 'NotEmpty' ],
34
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100000 ] ],
35 35
                 ],
36 36
             ]);
37 37
 
38 38
             $inputFilter->add([
39 39
                 'name'       => 'lead',
40 40
                 'required'   => true,
41
-                'filters'    => [['name' => 'StringTrim']],
41
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
42 42
                 'validators' => [
43
-                    ['name' => 'NotEmpty'],
44
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 50000]],
43
+                    [ 'name' => 'NotEmpty' ],
44
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 50000 ] ],
45 45
                 ],
46 46
             ]);
47 47
 
48 48
             $inputFilter->add([
49 49
                 'name'     => 'has_layout',
50 50
                 'required' => false,
51
-                'filters'  => [['name' => 'Boolean']],
51
+                'filters'  => [ [ 'name' => 'Boolean' ] ],
52 52
             ]);
53 53
 
54 54
             $inputFilter->add([
55 55
                 'name'     => 'is_homepage',
56 56
                 'required' => false,
57
-                'filters'  => [['name' => 'Boolean']],
57
+                'filters'  => [ [ 'name' => 'Boolean' ] ],
58 58
             ]);
59 59
 
60 60
             $this->inputFilter = $inputFilter;
Please login to merge, or discard this patch.
src/Article/src/Service/PostService.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Article\Service;
6 6
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $article = $this->articlePostsMapper->getBySlug($slug);
73 73
 
74
-        if($article) {
75
-            $article['categories'] = $this->getCategoryIds($article->article_uuid);
74
+        if ($article) {
75
+            $article[ 'categories' ] = $this->getCategoryIds($article->article_uuid);
76 76
         }
77 77
 
78 78
         return $article;
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $article = $this->articlePostsMapper->get($articleId);
84 84
 
85
-        if($article) {
86
-            $article['categories'] = $this->getCategoryIds($articleId);
85
+        if ($article) {
86
+            $article[ 'categories' ] = $this->getCategoryIds($articleId);
87 87
         }
88 88
 
89 89
         return $article;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $articleFilter = $this->articleFilter->getInputFilter()->setData($data);
95 95
         $postFilter    = $this->postFilter->getInputFilter()->setData($data);
96 96
 
97
-        if(!$articleFilter->isValid() || !$postFilter->isValid()) {
97
+        if (!$articleFilter->isValid() || !$postFilter->isValid()) {
98 98
             throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages());
99 99
         }
100 100
 
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
         $post = $postFilter->getValues() + [
112 112
                 'featured_img' => $this->upload->uploadImage($data, 'featured_img'),
113 113
                 'main_img'     => $this->upload->uploadImage($data, 'main_img'),
114
-                'article_uuid' => $article['article_uuid']
114
+                'article_uuid' => $article[ 'article_uuid' ]
115 115
             ];
116 116
 
117
-        if($post['is_homepage']) {
118
-            $this->articlePostsMapper->update(['is_homepage' => false]);
117
+        if ($post[ 'is_homepage' ]) {
118
+            $this->articlePostsMapper->update([ 'is_homepage' => false ]);
119 119
         }
120 120
 
121 121
         $this->articleMapper->insert($article);
122 122
         $this->articlePostsMapper->insert($post);
123 123
 
124
-        if(isset($data['categories']) && $data['categories']) {
125
-            $categories = $this->categoryMapper->select(['category_id' => $data['categories']]);
126
-            $this->articleMapper->insertCategories($categories, $article['article_uuid']);
124
+        if (isset($data[ 'categories' ]) && $data[ 'categories' ]) {
125
+            $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]);
126
+            $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]);
127 127
         }
128 128
     }
129 129
 
@@ -133,36 +133,36 @@  discard block
 block discarded – undo
133 133
         $articleFilter = $this->articleFilter->getInputFilter()->setData($data);
134 134
         $postFilter    = $this->postFilter->getInputFilter()->setData($data);
135 135
 
136
-        if(!$articleFilter->isValid() || !$postFilter->isValid()) {
136
+        if (!$articleFilter->isValid() || !$postFilter->isValid()) {
137 137
             throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages());
138 138
         }
139 139
 
140
-        $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid];
140
+        $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ];
141 141
         $post    = $postFilter->getValues() + [
142 142
                 'featured_img' => $this->upload->uploadImage($data, 'featured_img'),
143 143
                 'main_img'     => $this->upload->uploadImage($data, 'main_img')
144 144
             ];
145 145
 
146 146
         // We dont want to force user to re-upload image on edit
147
-        if(!$post['featured_img']) {
148
-            unset($post['featured_img']);
147
+        if (!$post[ 'featured_img' ]) {
148
+            unset($post[ 'featured_img' ]);
149 149
         }
150 150
 
151
-        if(!$post['main_img']) {
152
-            unset($post['main_img']);
151
+        if (!$post[ 'main_img' ]) {
152
+            unset($post[ 'main_img' ]);
153 153
         }
154 154
 
155
-        if($post['is_homepage']) {
156
-            $this->articlePostsMapper->update(['is_homepage' => false]);
155
+        if ($post[ 'is_homepage' ]) {
156
+            $this->articlePostsMapper->update([ 'is_homepage' => false ]);
157 157
         }
158 158
 
159
-        $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]);
160
-        $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]);
161
-        $this->articleMapper->deleteCategories($article['article_uuid']);
159
+        $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
160
+        $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
161
+        $this->articleMapper->deleteCategories($article[ 'article_uuid' ]);
162 162
 
163
-        if(isset($data['categories']) && $data['categories']) {
164
-            $categories = $this->categoryMapper->select(['category_id' => $data['categories']]);
165
-            $this->articleMapper->insertCategories($categories, $article['article_uuid']);
163
+        if (isset($data[ 'categories' ]) && $data[ 'categories' ]) {
164
+            $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]);
165
+            $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]);
166 166
         }
167 167
     }
168 168
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
     {
171 171
         $post = $this->articlePostsMapper->get($id);
172 172
 
173
-        if(!$post) {
173
+        if (!$post) {
174 174
             throw new \Exception('Article not found!');
175 175
         }
176 176
 
177
-        $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]);
177
+        $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]);
178 178
         $this->delete($post->article_uuid);
179 179
     }
180 180
 
Please login to merge, or discard this patch.