Completed
Push — master ( f0bac9...571456 )
by Aleksandar
79:09 queued 61:01
created
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_id);
74
+        if ($article) {
75
+            $article[ 'categories' ] = $this->getCategoryIds($article->article_id);
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;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $articleFilter = $this->articleFilter->getInputFilter()->setData($data);
103 103
         $postFilter    = $this->postFilter->getInputFilter()->setData($data);
104 104
 
105
-        if(!$articleFilter->isValid() || !$postFilter->isValid()) {
105
+        if (!$articleFilter->isValid() || !$postFilter->isValid()) {
106 106
             throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages());
107 107
         }
108 108
 
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
         $post = $postFilter->getValues() + [
120 120
                 'featured_img' => $this->upload->uploadImage($data, 'featured_img'),
121 121
                 'main_img'     => $this->upload->uploadImage($data, 'main_img'),
122
-                'article_uuid' => $article['article_uuid']
122
+                'article_uuid' => $article[ 'article_uuid' ]
123 123
             ];
124 124
 
125
-        if($post['is_homepage']) {
126
-            $this->articlePostsMapper->update(['is_homepage' => false]);
125
+        if ($post[ 'is_homepage' ]) {
126
+            $this->articlePostsMapper->update([ 'is_homepage' => false ]);
127 127
         }
128 128
 
129 129
         $this->articleMapper->insert($article);
130 130
         $this->articlePostsMapper->insert($post);
131 131
 
132
-        if(isset($data['categories']) && $data['categories']) {
133
-            $categories = $this->categoryMapper->select(['category_id' => $data['categories']]);
134
-            $this->articleMapper->insertCategories($categories, $article['article_uuid']);
132
+        if (isset($data[ 'categories' ]) && $data[ 'categories' ]) {
133
+            $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]);
134
+            $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]);
135 135
         }
136 136
     }
137 137
 
@@ -141,36 +141,36 @@  discard block
 block discarded – undo
141 141
         $articleFilter = $this->articleFilter->getInputFilter()->setData($data);
142 142
         $postFilter    = $this->postFilter->getInputFilter()->setData($data);
143 143
 
144
-        if(!$articleFilter->isValid() || !$postFilter->isValid()) {
144
+        if (!$articleFilter->isValid() || !$postFilter->isValid()) {
145 145
             throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages());
146 146
         }
147 147
 
148
-        $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid];
148
+        $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ];
149 149
         $post    = $postFilter->getValues() + [
150 150
                 'featured_img' => $this->upload->uploadImage($data, 'featured_img'),
151 151
                 'main_img'     => $this->upload->uploadImage($data, 'main_img')
152 152
             ];
153 153
 
154 154
         // We dont want to force user to re-upload image on edit
155
-        if(!$post['featured_img']) {
156
-            unset($post['featured_img']);
155
+        if (!$post[ 'featured_img' ]) {
156
+            unset($post[ 'featured_img' ]);
157 157
         }
158 158
 
159
-        if(!$post['main_img']) {
160
-            unset($post['main_img']);
159
+        if (!$post[ 'main_img' ]) {
160
+            unset($post[ 'main_img' ]);
161 161
         }
162 162
 
163
-        if($post['is_homepage']) {
164
-            $this->articlePostsMapper->update(['is_homepage' => false]);
163
+        if ($post[ 'is_homepage' ]) {
164
+            $this->articlePostsMapper->update([ 'is_homepage' => false ]);
165 165
         }
166 166
 
167
-        $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]);
168
-        $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]);
169
-        $this->articleMapper->deleteCategories($article['article_uuid']);
167
+        $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
168
+        $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
169
+        $this->articleMapper->deleteCategories($article[ 'article_uuid' ]);
170 170
 
171
-        if(isset($data['categories']) && $data['categories']) {
172
-            $categories = $this->categoryMapper->select(['category_id' => $data['categories']]);
173
-            $this->articleMapper->insertCategories($categories, $article['article_uuid']);
171
+        if (isset($data[ 'categories' ]) && $data[ 'categories' ]) {
172
+            $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]);
173
+            $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]);
174 174
         }
175 175
     }
176 176
 
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $post = $this->articlePostsMapper->get($id);
180 180
 
181
-        if(!$post) {
181
+        if (!$post) {
182 182
             throw new \Exception('Article not found!');
183 183
         }
184 184
 
185
-        $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]);
185
+        $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]);
186 186
         $this->delete($post->article_uuid);
187 187
     }
188 188
 
Please login to merge, or discard this patch.
src/Article/src/Mapper/ArticlePostsMapper.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Article\Mapper;
5 5
 
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
     public function getPaginationSelect()
35 35
     {
36 36
         return $this->getSql()->select()
37
-            ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'is_homepage'])
37
+            ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'is_homepage' ])
38 38
             ->join('articles', 'article_posts.article_uuid = articles.article_uuid')
39
-            ->where(['articles.type' => ArticleType::POST])
40
-            ->order(['created_at' => 'desc']);
39
+            ->where([ 'articles.type' => ArticleType::POST ])
40
+            ->order([ 'created_at' => 'desc' ]);
41 41
     }
42 42
 
43 43
     public function get($id)
44 44
     {
45 45
         $select = $this->getSql()->select()
46
-            ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout', 'is_homepage'])
46
+            ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout', 'is_homepage' ])
47 47
             ->join('articles', 'article_posts.article_uuid = articles.article_uuid')
48
-            ->where(['articles.article_id' => $id]);
48
+            ->where([ 'articles.article_id' => $id ]);
49 49
 
50 50
         return $this->selectWith($select)->current();
51 51
     }
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $select = $this->getSql()->select()
56 56
             ->join('articles', 'article_posts.article_uuid = articles.article_uuid')
57
-            ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', [])
58
-            ->join('category', 'category.category_uuid = article_categories.category_uuid', ['category_slug' => 'slug'])
57
+            ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', [ ])
58
+            ->join('category', 'category.category_uuid = article_categories.category_uuid', [ 'category_slug' => 'slug' ])
59 59
             ->limit(1);
60 60
 
61
-        if($direction > 0) {
61
+        if ($direction > 0) {
62 62
             $select->where->greaterThan('published_at', $publishedAt);
63
-            $select->order(['published_at' => 'asc']);
64
-        } elseif($direction < 0) {
63
+            $select->order([ 'published_at' => 'asc' ]);
64
+        } elseif ($direction < 0) {
65 65
             $select->where->lessThan('published_at', $publishedAt);
66
-            $select->order(['published_at' => 'desc']);
66
+            $select->order([ 'published_at' => 'desc' ]);
67 67
         }
68 68
 
69 69
         return $this->selectWith($select)->current();
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $select = $this->getSql()->select()
75 75
             ->join('articles', 'article_posts.article_uuid = articles.article_uuid')
76
-            ->where(['article_posts.is_homepage' => true, 'articles.status' => 1]);
76
+            ->where([ 'article_posts.is_homepage' => true, 'articles.status' => 1 ]);
77 77
 
78 78
         return $this->selectWith($select)->current();
79 79
     }
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
     public function getBySlug($slug)
82 82
     {
83 83
         $select = $this->getSql()->select()
84
-            ->columns(['title', 'body', 'lead', 'featured_img', 'main_img'])
84
+            ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ])
85 85
             ->join('articles', 'article_posts.article_uuid = articles.article_uuid')
86
-            ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', [])
87
-            ->join('category', 'category.category_uuid = article_categories.category_uuid', ['category_name' => 'name', 'category_slug' => 'slug'])
88
-            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name'])
89
-            ->where(['articles.slug' => $slug, 'articles.status' => 1]);
86
+            ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', [ ])
87
+            ->join('category', 'category.category_uuid = article_categories.category_uuid', [ 'category_name' => 'name', 'category_slug' => 'slug' ])
88
+            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ])
89
+            ->where([ 'articles.slug' => $slug, 'articles.status' => 1 ]);
90 90
 
91 91
         return $this->selectWith($select)->current();
92 92
     }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     public function getAll()
95 95
     {
96 96
         $select = $this->getSql()->select()
97
-            ->join('articles', 'article_posts.article_uuid = articles.article_uuid', ['article_id', 'slug']);
97
+            ->join('articles', 'article_posts.article_uuid = articles.article_uuid', [ 'article_id', 'slug' ]);
98 98
 
99 99
         return $this->selectWith($select);
100 100
     }
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $select = $this->getSql()->select()
108 108
             ->join('articles', 'article_posts.article_uuid = articles.article_uuid')
109
-            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name'])
109
+            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ])
110 110
             ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid')
111 111
             ->join('category', 'category.category_uuid = article_categories.category_uuid',
112
-                ['category_name' => 'name', 'category_id', 'category_slug' => 'slug'])
113
-            ->where(['articles.status' => 1])
114
-            ->order(['articles.published_at' => 'desc'])
112
+                [ 'category_name' => 'name', 'category_id', 'category_slug' => 'slug' ])
113
+            ->where([ 'articles.status' => 1 ])
114
+            ->order([ 'articles.published_at' => 'desc' ])
115 115
             ->limit($limit);
116 116
 
117 117
         return $this->selectWith($select);
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/Admin/src/Controller/UserController.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 Admin\Controller;
6 6
 
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $user   = $this->session->getStorage()->user;
66 66
         $params = $this->request->getQueryParams();
67
-        $page   = isset($params['page']) ? $params['page'] : 1;
68
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
67
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
68
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
69 69
 
70 70
         $adminUsers = $this->adminUserService->getPagination($page, $limit, $user->admin_user_id);
71 71
 
72
-        return new HtmlResponse($this->template->render('admin::user/index', ['list' => $adminUsers, 'layout' => 'layout/admin']));
72
+        return new HtmlResponse($this->template->render('admin::user/index', [ 'list' => $adminUsers, 'layout' => 'layout/admin' ]));
73 73
     }
74 74
 
75 75
     /**
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
      *
78 78
      * @return \Psr\Http\Message\ResponseInterface
79 79
      */
80
-    public function edit($errors = []): \Psr\Http\Message\ResponseInterface
80
+    public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface
81 81
     {
82 82
         $id   = $this->request->getAttribute('id');
83 83
         $user = $this->adminUserService->getUser($id);
84 84
 
85
-        if($this->request->getParsedBody()) {
86
-            $user                = (object)($this->request->getParsedBody() + (array)$user);
85
+        if ($this->request->getParsedBody()) {
86
+            $user                = (object) ($this->request->getParsedBody() + (array) $user);
87 87
             $user->admin_user_id = $id;
88 88
         }
89 89
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
         try {
100 100
             $userId = $this->request->getAttribute('id');
101 101
             $data   = $this->request->getParsedBody();
102
-            $data   += (new Request())->getFiles()->toArray();
102
+            $data += (new Request())->getFiles()->toArray();
103 103
 
104
-            if($userId) {
104
+            if ($userId) {
105 105
                 $this->adminUserService->updateUser($data, $userId);
106 106
             }
107 107
             else {
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 
111 111
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users'));
112 112
         }
113
-        catch(FilterException $fe) {
113
+        catch (FilterException $fe) {
114 114
             return $this->edit($fe->getArrayMessages());
115 115
         }
116
-        catch(\Exception $e) {
116
+        catch (\Exception $e) {
117 117
             throw $e;
118 118
         }
119 119
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users'));
128 128
         }
129
-        catch(\Exception $e) {
129
+        catch (\Exception $e) {
130 130
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users'));
131 131
         }
132 132
     }
Please login to merge, or discard this patch.
src/Category/src/View/Helper/CategoryHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      */
34 34
     public function forWeb()
35 35
     {
36
-        if(!$this->categoriesWithPosts) {
36
+        if (!$this->categoriesWithPosts) {
37 37
             $this->categoriesWithPosts = $this->categoryService->getWebCategories();
38 38
         }
39 39
 
Please login to merge, or discard this patch.
src/Category/src/Service/CategoryService.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Category\Service;
5 5
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getCategoryBySlug($urlSlug)
71 71
     {
72
-        return $this->categoryMapper->select(['slug' => $urlSlug])->current();
72
+        return $this->categoryMapper->select([ 'slug' => $urlSlug ])->current();
73 73
     }
74 74
 
75 75
     /**
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $filter = $this->categoryFilter->getInputFilter()->setData($data);
84 84
 
85
-        if(!$filter->isValid()) {
85
+        if (!$filter->isValid()) {
86 86
             throw new FilterException($filter->getMessages());
87 87
         }
88 88
 
89 89
         $data                  = $filter->getValues();
90
-        $data['category_id']   = Uuid::uuid1()->toString();
91
-        $data['category_uuid'] = (new MysqlUuid($data['category_id']))->toFormat(new Binary);
90
+        $data[ 'category_id' ]   = Uuid::uuid1()->toString();
91
+        $data[ 'category_uuid' ] = (new MysqlUuid($data[ 'category_id' ]))->toFormat(new Binary);
92 92
 
93 93
         $this->categoryMapper->insert($data);
94 94
     }
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function updateCategory($data, $categoryId)
105 105
     {
106
-        if(!$this->getCategory($categoryId)) {
106
+        if (!$this->getCategory($categoryId)) {
107 107
             throw new \Exception('CategoryId dos not exist.');
108 108
         }
109 109
 
110 110
         $filter = $this->categoryFilter->getInputFilter()->setData($data);
111 111
 
112
-        if(!$filter->isValid()) {
112
+        if (!$filter->isValid()) {
113 113
             throw new FilterException($filter->getMessages());
114 114
         }
115 115
 
116 116
         $data = $filter->getValues();
117
-        $this->categoryMapper->update($data, ['category_id' => $categoryId]);
117
+        $this->categoryMapper->update($data, [ 'category_id' => $categoryId ]);
118 118
     }
119 119
 
120 120
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function delete($categoryId)
127 127
     {
128
-        return (bool)$this->categoryMapper->delete(['category_id' => $categoryId]);
128
+        return (bool) $this->categoryMapper->delete([ 'category_id' => $categoryId ]);
129 129
     }
130 130
 
131 131
     /**
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     {
146 146
         $categories = $this->categoryMapper->getWeb()->toArray();
147 147
 
148
-        foreach($categories as $ctn => $category) {
149
-            $select                    = $this->categoryMapper->getCategoryPostsSelect($category['category_id'], 4);
148
+        foreach ($categories as $ctn => $category) {
149
+            $select                    = $this->categoryMapper->getCategoryPostsSelect($category[ 'category_id' ], 4);
150 150
             $posts                     = $this->categoryMapper->selectWith($select)->toArray();
151
-            $categories[$ctn]['posts'] = $posts;
151
+            $categories[ $ctn ][ 'posts' ] = $posts;
152 152
         }
153 153
 
154 154
         return $categories;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function allWeb()
161 161
     {
162
-        return $this->categoryMapper->getWeb(null, ['name' => 'asc']);
162
+        return $this->categoryMapper->getWeb(null, [ 'name' => 'asc' ]);
163 163
     }
164 164
 
165 165
     /**
Please login to merge, or discard this patch.
src/Category/src/Mapper/CategoryMapper.php 1 patch
Spacing   +16 added lines, -16 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 Category\Mapper;
6 6
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function get($id)
36 36
     {
37
-        return $this->select(['category_id' => $id])->current();
37
+        return $this->select([ 'category_id' => $id ])->current();
38 38
     }
39 39
 
40 40
     public function getPaginationSelect()
41 41
     {
42
-        $select = $this->getSql()->select()->order(['name' => 'asc']);
42
+        $select = $this->getSql()->select()->order([ 'name' => 'asc' ]);
43 43
 
44 44
         return $select;
45 45
     }
@@ -47,19 +47,19 @@  discard block
 block discarded – undo
47 47
     public function getCategoryPostsSelect($categoryId = null, $limit = null)
48 48
     {
49 49
         $select = $this->getSql()->select()
50
-            ->columns(['category_name' => 'name', 'category_slug' => 'slug'])
51
-            ->join('article_categories', 'article_categories.category_uuid = category.category_uuid', [])
52
-            ->join('articles', 'articles.article_uuid = article_categories.article_uuid', ['article_id', 'slug', 'admin_user_uuid', 'published_at'])
53
-            ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', ['*'], 'right')
54
-            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name', 'face_img'])
55
-            ->where(['articles.status' => 1])
56
-            ->order(['published_at' => 'desc']);
57
-
58
-        if($categoryId) {
59
-            $select->where(['category_id' => $categoryId]);
50
+            ->columns([ 'category_name' => 'name', 'category_slug' => 'slug' ])
51
+            ->join('article_categories', 'article_categories.category_uuid = category.category_uuid', [ ])
52
+            ->join('articles', 'articles.article_uuid = article_categories.article_uuid', [ 'article_id', 'slug', 'admin_user_uuid', 'published_at' ])
53
+            ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', [ '*' ], 'right')
54
+            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name', 'face_img' ])
55
+            ->where([ 'articles.status' => 1 ])
56
+            ->order([ 'published_at' => 'desc' ]);
57
+
58
+        if ($categoryId) {
59
+            $select->where([ 'category_id' => $categoryId ]);
60 60
         }
61 61
 
62
-        if($limit) {
62
+        if ($limit) {
63 63
             $select->limit($limit);
64 64
         }
65 65
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
         $select->where->notEqualTo('slug', 'php-videos');
76 76
         $select->where->notEqualTo('slug', 'events');
77 77
 
78
-        if($limit) {
78
+        if ($limit) {
79 79
             $select->limit($limit);
80 80
         }
81 81
 
82
-        if($order) {
82
+        if ($order) {
83 83
             $select->order($order);
84 84
         } else {
85 85
             $select->order(new Expression('rand()'));
Please login to merge, or discard this patch.
src/Core/Filter/AdminUserFilter.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -19,37 +19,37 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function getInputFilter()
21 21
     {
22
-        if(!$this->inputFilter) {
22
+        if (!$this->inputFilter) {
23 23
             $inputFilter = new InputFilter();
24 24
 
25 25
             $inputFilter->add([
26 26
                 'name'       => 'first_name',
27 27
                 'required'   => true,
28
-                'filters'    => [['name' => 'StringTrim']],
28
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
29 29
                 'validators' => [
30
-                    ['name' => 'NotEmpty'],
31
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]]
30
+                    [ 'name' => 'NotEmpty' ],
31
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ]
32 32
                 ],
33 33
             ]);
34 34
 
35 35
             $inputFilter->add([
36 36
                 'name'       => 'last_name',
37 37
                 'required'   => true,
38
-                'filters'    => [['name' => 'StringTrim']],
38
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
39 39
                 'validators' => [
40
-                    ['name' => 'NotEmpty'],
41
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]]
40
+                    [ 'name' => 'NotEmpty' ],
41
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ]
42 42
                 ],
43 43
             ]);
44 44
 
45 45
             $inputFilter->add([
46 46
                 'name'       => 'email',
47 47
                 'required'   => true,
48
-                'filters'    => [['name' => 'StringTrim']],
48
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
49 49
                 'validators' => [
50
-                    ['name' => 'NotEmpty'],
51
-                    ['name' => 'EmailAddress'],
52
-                    ['name' => 'dbnorecordexists', 'options' => ['adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email']],
50
+                    [ 'name' => 'NotEmpty' ],
51
+                    [ 'name' => 'EmailAddress' ],
52
+                    [ 'name' => 'dbnorecordexists', 'options' => [ 'adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email' ] ],
53 53
 
54 54
                 ],
55 55
             ]);
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
             $inputFilter->add([
58 58
                 'name'     => 'introduction',
59 59
                 'required' => false,
60
-                'filters'  => [['name' => 'StringTrim']]
60
+                'filters'  => [ [ 'name' => 'StringTrim' ] ]
61 61
             ]);
62 62
 
63 63
             $inputFilter->add([
64 64
                 'name'       => 'password',
65 65
                 'required'   => true,
66 66
                 'validators' => [
67
-                    ['name' => 'NotEmpty'],
68
-                    ['name' => 'StringLength', 'options' => ['min' => 7, 'max' => 255]]
67
+                    [ 'name' => 'NotEmpty' ],
68
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 7, 'max' => 255 ] ]
69 69
                 ],
70 70
             ]);
71 71
 
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
                 'name'       => 'confirm_password',
74 74
                 'required'   => true,
75 75
                 'validators' => [
76
-                    ['name' => 'NotEmpty'],
77
-                    ['name' => 'Identical', 'options' => ['token' => 'password']],
76
+                    [ 'name' => 'NotEmpty' ],
77
+                    [ 'name' => 'Identical', 'options' => [ 'token' => 'password' ] ],
78 78
                 ],
79 79
             ]);
80 80
 
81 81
             $inputFilter->add([
82 82
                 'name'       => 'status',
83 83
                 'required'   => true,
84
-                'validators' => [['name' => 'NotEmpty'], ['name' => 'Digits']]
84
+                'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Digits' ] ]
85 85
             ]);
86 86
 
87 87
             $this->inputFilter = $inputFilter;
Please login to merge, or discard this patch.
src/Core/Service/AdminUserService.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Core\Service;
5 5
 
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function loginUser($email, $password)
63 63
     {
64
-        if(!$email || !$password) {
64
+        if (!$email || !$password) {
65 65
             throw new \Exception('Both email and password are required.', 400);
66 66
         }
67 67
 
68 68
         $user = $this->adminUsersMapper->getByEmail($email);
69 69
 
70
-        if(!$user) {
70
+        if (!$user) {
71 71
             throw new \Exception('User does not exist.');
72 72
         }
73 73
 
74
-        if(!$this->crypt->verify($password, $user->password)) {
74
+        if (!$this->crypt->verify($password, $user->password)) {
75 75
             throw new \Exception('Password does not match.');
76 76
         }
77 77
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $filter = $this->adminUserFilter->getInputFilter()->setData($data);
119 119
 
120
-        if(!$filter->isValid()) {
120
+        if (!$filter->isValid()) {
121 121
             throw new FilterException($filter->getMessages());
122 122
         }
123 123
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
                 'profile_img' => $this->upload->uploadImage($data, 'profile_img')
127 127
             ];
128 128
 
129
-        unset($data['confirm_password']);
130
-        $data['password']        = $this->crypt->create($data['password']);
131
-        $data['admin_user_id']   = Uuid::uuid1()->toString();
132
-        $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary);
129
+        unset($data[ 'confirm_password' ]);
130
+        $data[ 'password' ]        = $this->crypt->create($data[ 'password' ]);
131
+        $data[ 'admin_user_id' ]   = Uuid::uuid1()->toString();
132
+        $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary);
133 133
 
134 134
         return $this->adminUsersMapper->insert($data);
135 135
     }
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
         $filter = $this->adminUserFilter->getInputFilter()->setData($data);
144 144
 
145 145
         // we dont want to force user to enter the password again
146
-        if($data['password'] == '') {
146
+        if ($data[ 'password' ] == '') {
147 147
             $filter->remove('password');
148 148
             $filter->remove('confirm_password');
149 149
         }
150 150
 
151 151
         // if we want to keep same email
152
-        if($user->email == $data['email']) {
152
+        if ($user->email == $data[ 'email' ]) {
153 153
             $filter->remove('email');
154 154
         }
155 155
 
156
-        if(!$filter->isValid()) {
156
+        if (!$filter->isValid()) {
157 157
             throw new FilterException($filter->getMessages());
158 158
         }
159 159
 
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
             ];
164 164
 
165 165
         // We dont want to force user to re-upload image on edit
166
-        if(!$data['face_img']) {
167
-            unset($data['face_img']);
166
+        if (!$data[ 'face_img' ]) {
167
+            unset($data[ 'face_img' ]);
168 168
         }
169 169
 
170
-        if(!$data['profile_img']) {
171
-            unset($data['profile_img']);
170
+        if (!$data[ 'profile_img' ]) {
171
+            unset($data[ 'profile_img' ]);
172 172
         }
173 173
 
174
-        if(isset($data['password'])) {
175
-            unset($data['confirm_password']);
176
-            $data['password'] = $this->crypt->create($data['password']);
174
+        if (isset($data[ 'password' ])) {
175
+            unset($data[ 'confirm_password' ]);
176
+            $data[ 'password' ] = $this->crypt->create($data[ 'password' ]);
177 177
         }
178 178
 
179
-        return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]);
179
+        return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]);
180 180
     }
181 181
 
182 182
     /**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function delete($userId)
189 189
     {
190
-        return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]);
190
+        return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]);
191 191
     }
192 192
 
193 193
     /**
Please login to merge, or discard this patch.