@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Service; |
6 | 6 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
96 | 96 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
97 | 97 | |
98 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
98 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
99 | 99 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
100 | 100 | } |
101 | 101 | |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | |
105 | 105 | $article = $articleFilter->getValues(); |
106 | 106 | $article += [ |
107 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
107 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
108 | 108 | 'type' => ArticleType::POST, |
109 | 109 | 'article_id' => $id, |
110 | 110 | 'article_uuid' => $uuId |
111 | 111 | ]; |
112 | 112 | |
113 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
114 | - unset($article['category_id'], $article['admin_user_id']); |
|
113 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
114 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
115 | 115 | |
116 | 116 | $post = $postFilter->getValues() + [ |
117 | 117 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
118 | 118 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
119 | - 'article_uuid' => $article['article_uuid'] |
|
119 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
120 | 120 | ]; |
121 | 121 | |
122 | 122 | $this->articleMapper->insert($article); |
@@ -129,37 +129,37 @@ discard block |
||
129 | 129 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
130 | 130 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
131 | 131 | |
132 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
132 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
133 | 133 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
134 | 134 | } |
135 | 135 | |
136 | - $article = $articleFilter->getValues() + ['article_uuid' => $oldArticle->article_uuid]; |
|
136 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->article_uuid ]; |
|
137 | 137 | $post = $postFilter->getValues() + [ |
138 | 138 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
139 | 139 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
140 | 140 | ]; |
141 | 141 | |
142 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
143 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
144 | - unset($article['category_id'], $article['admin_user_id']); |
|
142 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
143 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
144 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
145 | 145 | |
146 | 146 | // We don't 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 | else { |
151 | 151 | $this->upload->deleteFile($oldArticle->featured_img); |
152 | 152 | } |
153 | 153 | |
154 | - if (!$post['main_img']) { |
|
155 | - unset($post['main_img']); |
|
154 | + if (!$post[ 'main_img' ]) { |
|
155 | + unset($post[ 'main_img' ]); |
|
156 | 156 | } |
157 | 157 | else { |
158 | 158 | $this->upload->deleteFile($oldArticle->main_img); |
159 | 159 | } |
160 | 160 | |
161 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
162 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
161 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
162 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | public function deleteArticle($id) |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $this->upload->deleteFile($post->main_img); |
174 | 174 | $this->upload->deleteFile($post->featured_img); |
175 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
175 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
176 | 176 | $this->delete($post->article_uuid); |
177 | 177 | } |
178 | 178 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Service; |
6 | 6 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
107 | 107 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
108 | 108 | |
109 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
109 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
110 | 110 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
111 | 111 | } |
112 | 112 | |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | |
116 | 116 | $article = $articleFilter->getValues(); |
117 | 117 | $article += [ |
118 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
118 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
119 | 119 | 'type' => ArticleType::VIDEO, |
120 | 120 | 'article_id' => $id, |
121 | 121 | 'article_uuid' => $uuId |
122 | 122 | ]; |
123 | 123 | |
124 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
125 | - unset($article['category_id'], $article['admin_user_id']); |
|
124 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
125 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
126 | 126 | |
127 | 127 | $videos = $videosFilter->getValues() + [ |
128 | 128 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
141 | 141 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
142 | 142 | |
143 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
143 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
144 | 144 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
145 | 145 | } |
146 | 146 | |
147 | - $article = $articleFilter->getValues() + ['article_uuid' => $oldArticle->article_uuid]; |
|
148 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
149 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
150 | - unset($article['category_id']); |
|
151 | - unset($article['admin_user_id']); |
|
147 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->article_uuid ]; |
|
148 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
149 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
150 | + unset($article[ 'category_id' ]); |
|
151 | + unset($article[ 'admin_user_id' ]); |
|
152 | 152 | |
153 | 153 | $videos = $videosFilter->getValues() + [ |
154 | 154 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -156,35 +156,35 @@ discard block |
||
156 | 156 | ]; |
157 | 157 | |
158 | 158 | // We don't want to force user to re-upload image on edit |
159 | - if(!$videos['featured_img']) { |
|
160 | - unset($videos['featured_img']); |
|
159 | + if (!$videos[ 'featured_img' ]) { |
|
160 | + unset($videos[ 'featured_img' ]); |
|
161 | 161 | } |
162 | 162 | else { |
163 | 163 | $this->upload->deleteFile($oldArticle->featured_img); |
164 | 164 | } |
165 | 165 | |
166 | - if(!$videos['main_img']) { |
|
167 | - unset($videos['main_img']); |
|
166 | + if (!$videos[ 'main_img' ]) { |
|
167 | + unset($videos[ 'main_img' ]); |
|
168 | 168 | } |
169 | 169 | else { |
170 | 170 | $this->upload->deleteFile($oldArticle->main_img); |
171 | 171 | } |
172 | 172 | |
173 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
174 | - $this->articleVideosMapper->update($videos, ['article_uuid' => $article['article_uuid']]); |
|
173 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
174 | + $this->articleVideosMapper->update($videos, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | public function deleteArticle($id) |
178 | 178 | { |
179 | 179 | $video = $this->articleVideosMapper->get($id); |
180 | 180 | |
181 | - if(!$video) { |
|
181 | + if (!$video) { |
|
182 | 182 | throw new \Exception('Article not found!'); |
183 | 183 | } |
184 | 184 | |
185 | 185 | $this->upload->deleteFile($video->main_img); |
186 | 186 | $this->upload->deleteFile($video->featured_img); |
187 | - $this->articleVideosMapper->delete(['article_uuid' => $video->article_uuid]); |
|
187 | + $this->articleVideosMapper->delete([ 'article_uuid' => $video->article_uuid ]); |
|
188 | 188 | $this->delete($video->article_uuid); |
189 | 189 | } |
190 | 190 |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | - public function edit($errors = []) |
|
56 | + public function edit($errors = [ ]) |
|
57 | 57 | { |
58 | 58 | $id = $this->request->getAttribute('id'); |
59 | 59 | $item = $this->menuService->get($id); |
60 | 60 | |
61 | - if($this->request->getParsedBody()) { |
|
62 | - $item = (object)($this->request->getParsedBody() + (array)$item); |
|
61 | + if ($this->request->getParsedBody()) { |
|
62 | + $item = (object) ($this->request->getParsedBody() + (array) $item); |
|
63 | 63 | $item->menu_id = $id; |
64 | 64 | } |
65 | 65 | |
@@ -78,36 +78,36 @@ discard block |
||
78 | 78 | |
79 | 79 | public function save() |
80 | 80 | { |
81 | - try{ |
|
81 | + try { |
|
82 | 82 | $id = $this->request->getAttribute('id'); |
83 | 83 | $data = $this->request->getParsedBody(); |
84 | 84 | |
85 | - if($id) { |
|
85 | + if ($id) { |
|
86 | 86 | $this->menuService->updateMenuItem($data, $id); |
87 | 87 | } |
88 | - else{ |
|
88 | + else { |
|
89 | 89 | $this->menuService->addMenuItem($data); |
90 | 90 | } |
91 | 91 | |
92 | 92 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.menu')); |
93 | 93 | } |
94 | - catch(FilterException $fe){ |
|
94 | + catch (FilterException $fe) { |
|
95 | 95 | return $this->edit($fe->getArrayMessages()); |
96 | 96 | } |
97 | - catch(\Exception $e){ |
|
97 | + catch (\Exception $e) { |
|
98 | 98 | throw $e; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | 102 | public function delete() |
103 | 103 | { |
104 | - try{ |
|
104 | + try { |
|
105 | 105 | $id = $this->request->getAttribute('id'); |
106 | 106 | $this->menuService->delete($id); |
107 | 107 | |
108 | 108 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.menu')); |
109 | 109 | } |
110 | - catch(\Exception $e){ |
|
110 | + catch (\Exception $e) { |
|
111 | 111 | throw $e; |
112 | 112 | } |
113 | 113 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | public function updateOrder() |
116 | 116 | { |
117 | 117 | $data = $this->request->getParsedBody(); |
118 | - $menuOrder = isset($data['order']) ? json_decode($data['order']) : []; |
|
118 | + $menuOrder = isset($data[ 'order' ]) ? json_decode($data[ 'order' ]) : [ ]; |
|
119 | 119 | $status = $this->menuService->updateMenuOrder($menuOrder); |
120 | 120 | |
121 | - return new JsonResponse(['status' => $status]); |
|
121 | + return new JsonResponse([ 'status' => $status ]); |
|
122 | 122 | } |
123 | 123 | } |
@@ -29,16 +29,16 @@ |
||
29 | 29 | |
30 | 30 | public function getHeaderMenu() |
31 | 31 | { |
32 | - return $this->menuService->getNestedAll(true, ['is_in_header' => true]); |
|
32 | + return $this->menuService->getNestedAll(true, [ 'is_in_header' => true ]); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function getFooterMenu() |
36 | 36 | { |
37 | - return $this->menuService->getNestedAll(true, ['is_in_footer' => true]); |
|
37 | + return $this->menuService->getNestedAll(true, [ 'is_in_footer' => true ]); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getSideMenu() |
41 | 41 | { |
42 | - return $this->menuService->getNestedAll(true, ['is_in_side' => true]); |
|
42 | + return $this->menuService->getNestedAll(true, [ 'is_in_side' => true ]); |
|
43 | 43 | } |
44 | 44 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Mapper; |
6 | 6 | |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | public function getPaginationSelect($status = null) |
37 | 37 | { |
38 | 38 | $select = $this->getSql()->select() |
39 | - ->columns(['title', 'body', 'longitude', 'latitude']) |
|
39 | + ->columns([ 'title', 'body', 'longitude', 'latitude' ]) |
|
40 | 40 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
41 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name']) |
|
42 | - ->where(['articles.type' => ArticleType::EVENT]) |
|
43 | - ->order(['created_at' => 'desc']); |
|
41 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name' ]) |
|
42 | + ->where([ 'articles.type' => ArticleType::EVENT ]) |
|
43 | + ->order([ 'created_at' => 'desc' ]); |
|
44 | 44 | |
45 | - if($status) { |
|
46 | - $select->where(['articles.status' => (int)$status]); |
|
45 | + if ($status) { |
|
46 | + $select->where([ 'articles.status' => (int) $status ]); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $select; |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
56 | 56 | ->join( |
57 | 57 | 'category', 'category.category_uuid = articles.category_uuid', |
58 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
58 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
59 | 59 | ) |
60 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
61 | - ->where(['articles.article_id' => $id]); |
|
60 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
61 | + ->where([ 'articles.article_id' => $id ]); |
|
62 | 62 | |
63 | 63 | return $this->selectWith($select)->current(); |
64 | 64 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
70 | 70 | ->join( |
71 | 71 | 'category', 'category.category_uuid = articles.category_uuid', |
72 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
72 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
73 | 73 | ) |
74 | - ->where(['articles.slug' => $slug]); |
|
74 | + ->where([ 'articles.slug' => $slug ]); |
|
75 | 75 | |
76 | 76 | return $this->selectWith($select)->current(); |
77 | 77 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | public function getLatest($limit = 50) |
80 | 80 | { |
81 | 81 | $select = $this->getSql()->select() |
82 | - ->join('articles', 'article_events.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
83 | - ->where(['articles.status' => 1]) |
|
84 | - ->order(['published_at' => 'desc']) |
|
82 | + ->join('articles', 'article_events.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
83 | + ->where([ 'articles.status' => 1 ]) |
|
84 | + ->order([ 'published_at' => 'desc' ]) |
|
85 | 85 | ->limit($limit); |
86 | 86 | |
87 | 87 | return $this->selectWith($select); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | public function getFuture() |
91 | 91 | { |
92 | 92 | $select = $this->getSql()->select() |
93 | - ->where(['articles.status' => 1]) |
|
94 | - ->join('articles', 'articles.article_uuid = article_events.article_uuid', ['article_id', 'slug', 'published_at']) |
|
93 | + ->where([ 'articles.status' => 1 ]) |
|
94 | + ->join('articles', 'articles.article_uuid = article_events.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
95 | 95 | ->order(new Expression('rand()')); |
96 | 96 | |
97 | 97 | $select->where->greaterThanOrEqualTo('end_at', date('Y-m-d H:i:s')); |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | public function getPastSelect() |
103 | 103 | { |
104 | 104 | $select = $this->getSql()->select() |
105 | - ->where(['articles.status' => 1]) |
|
106 | - ->join('articles', 'articles.article_uuid = article_events.article_uuid', ['article_id', 'slug', 'published_at']) |
|
107 | - ->order(['start_at' => 'desc']); |
|
105 | + ->where([ 'articles.status' => 1 ]) |
|
106 | + ->join('articles', 'articles.article_uuid = article_events.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
107 | + ->order([ 'start_at' => 'desc' ]); |
|
108 | 108 | |
109 | 109 | $select->where->lessThan('end_at', date('Y-m-d H:i:s')); |
110 | 110 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Article\Mapper; |
5 | 5 | |
@@ -34,24 +34,24 @@ discard block |
||
34 | 34 | public function getPaginationSelect() |
35 | 35 | { |
36 | 36 | return $this->getSql()->select() |
37 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
37 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
38 | 38 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
39 | - ->join('category', 'articles.category_uuid = category.category_uuid', ['category_name' => 'name'], 'left') |
|
40 | - ->where(['articles.type' => ArticleType::POST]) |
|
41 | - ->order(['created_at' => 'desc']); |
|
39 | + ->join('category', 'articles.category_uuid = category.category_uuid', [ 'category_name' => 'name' ], 'left') |
|
40 | + ->where([ 'articles.type' => ArticleType::POST ]) |
|
41 | + ->order([ 'created_at' => 'desc' ]); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function get($id) |
45 | 45 | { |
46 | 46 | $select = $this->getSql()->select() |
47 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout']) |
|
47 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout' ]) |
|
48 | 48 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
49 | 49 | ->join( |
50 | 50 | 'category', 'category.category_uuid = articles.category_uuid', |
51 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
51 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
52 | 52 | ) |
53 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
54 | - ->where(['articles.article_id' => $id]); |
|
53 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
54 | + ->where([ 'articles.article_id' => $id ]); |
|
55 | 55 | |
56 | 56 | return $this->selectWith($select)->current(); |
57 | 57 | } |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | { |
61 | 61 | $select = $this->getSql()->select() |
62 | 62 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
63 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_slug' => 'slug']) |
|
64 | - ->where(['articles.status' => 1]) |
|
63 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_slug' => 'slug' ]) |
|
64 | + ->where([ 'articles.status' => 1 ]) |
|
65 | 65 | ->limit(1); |
66 | 66 | |
67 | - if($direction > 0) { |
|
67 | + if ($direction > 0) { |
|
68 | 68 | $select->where->greaterThan('published_at', $publishedAt); |
69 | - $select->order(['published_at' => 'asc']); |
|
70 | - } elseif($direction < 0) { |
|
69 | + $select->order([ 'published_at' => 'asc' ]); |
|
70 | + } elseif ($direction < 0) { |
|
71 | 71 | $select->where->lessThan('published_at', $publishedAt); |
72 | - $select->order(['published_at' => 'desc']); |
|
72 | + $select->order([ 'published_at' => 'desc' ]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return $this->selectWith($select)->current(); |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | public function getBySlug($slug) |
79 | 79 | { |
80 | 80 | $select = $this->getSql()->select() |
81 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
81 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
82 | 82 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
83 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_name' => 'name', 'category_slug' => 'slug']) |
|
84 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
85 | - ->where(['articles.slug' => $slug, 'articles.status' => 1]); |
|
83 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
84 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
85 | + ->where([ 'articles.slug' => $slug, 'articles.status' => 1 ]); |
|
86 | 86 | |
87 | 87 | return $this->selectWith($select)->current(); |
88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function getAll() |
91 | 91 | { |
92 | 92 | $select = $this->getSql()->select() |
93 | - ->join('articles', 'article_posts.article_uuid = articles.article_uuid', ['article_id', 'slug']); |
|
93 | + ->join('articles', 'article_posts.article_uuid = articles.article_uuid', [ 'article_id', 'slug' ]); |
|
94 | 94 | |
95 | 95 | return $this->selectWith($select); |
96 | 96 | } |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | { |
100 | 100 | $select = $this->getSql()->select() |
101 | 101 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
102 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
102 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
103 | 103 | ->join( |
104 | 104 | 'category', 'category.category_uuid = articles.category_uuid', |
105 | - ['category_name' => 'name', 'category_id', 'category_slug' => 'slug'] |
|
105 | + [ 'category_name' => 'name', 'category_id', 'category_slug' => 'slug' ] |
|
106 | 106 | ) |
107 | - ->where(['articles.status' => 1]) |
|
108 | - ->order(['articles.published_at' => 'desc']) |
|
107 | + ->where([ 'articles.status' => 1 ]) |
|
108 | + ->order([ 'articles.published_at' => 'desc' ]) |
|
109 | 109 | ->limit($limit); |
110 | 110 | |
111 | 111 | return $this->selectWith($select); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Mapper; |
6 | 6 | |
@@ -24,23 +24,23 @@ discard block |
||
24 | 24 | public function getPaginationSelect() |
25 | 25 | { |
26 | 26 | return $this->getSql()->select() |
27 | - ->columns(['title', 'body']) |
|
27 | + ->columns([ 'title', 'body' ]) |
|
28 | 28 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
29 | - ->where(['articles.type' => ArticleType::DISCUSSION]) |
|
30 | - ->order(['created_at' => 'desc']); |
|
29 | + ->where([ 'articles.type' => ArticleType::DISCUSSION ]) |
|
30 | + ->order([ 'created_at' => 'desc' ]); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function get($id) |
34 | 34 | { |
35 | 35 | $select = $this->getSql()->select() |
36 | - ->columns(['title', 'body']) |
|
36 | + ->columns([ 'title', 'body' ]) |
|
37 | 37 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
38 | 38 | ->join( |
39 | 39 | 'category', 'category.category_uuid = articles.category_uuid', |
40 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
40 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
41 | 41 | ) |
42 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
43 | - ->where(['articles.article_id' => $id]); |
|
42 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
43 | + ->where([ 'articles.article_id' => $id ]); |
|
44 | 44 | |
45 | 45 | return $this->selectWith($select)->current(); |
46 | 46 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Article\Mapper; |
5 | 5 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | public function getPaginationSelect($isActive = null) |
35 | 35 | { |
36 | 36 | $select = $this->getSql()->select() |
37 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['slug', 'published_at', 'status', 'article_id']) |
|
38 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name']) |
|
39 | - ->where(['articles.type' => ArticleType::VIDEO]) |
|
40 | - ->order(['articles.created_at' => 'desc']); |
|
37 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'slug', 'published_at', 'status', 'article_id' ]) |
|
38 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name' ]) |
|
39 | + ->where([ 'articles.type' => ArticleType::VIDEO ]) |
|
40 | + ->order([ 'articles.created_at' => 'desc' ]); |
|
41 | 41 | |
42 | - if($isActive !== null) { |
|
43 | - $select->where(['articles.status' => (int)$isActive]); |
|
42 | + if ($isActive !== null) { |
|
43 | + $select->where([ 'articles.status' => (int) $isActive ]); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $select; |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | public function get($id) |
50 | 50 | { |
51 | 51 | $select = $this->getSql()->select() |
52 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title']) |
|
52 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title' ]) |
|
53 | 53 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
54 | 54 | ->join( |
55 | 55 | 'category', 'category.category_uuid = articles.category_uuid', |
56 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
56 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
57 | 57 | ) |
58 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
59 | - ->where(['articles.article_id' => $id]); |
|
58 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
59 | + ->where([ 'articles.article_id' => $id ]); |
|
60 | 60 | |
61 | 61 | return $this->selectWith($select)->current(); |
62 | 62 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | public function getLatest($limit = 50) |
65 | 65 | { |
66 | 66 | $select = $this->getSql()->select() |
67 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
68 | - ->where(['articles.status' => 1]) |
|
69 | - ->order(['published_at' => 'desc']) |
|
67 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
68 | + ->where([ 'articles.status' => 1 ]) |
|
69 | + ->order([ 'published_at' => 'desc' ]) |
|
70 | 70 | ->limit($limit); |
71 | 71 | |
72 | 72 | return $this->selectWith($select); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $select = $this->getSql()->select() |
78 | 78 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
79 | - ->where(['articles.slug' => $slug]); |
|
79 | + ->where([ 'articles.slug' => $slug ]); |
|
80 | 80 | |
81 | 81 | return $this->selectWith($select)->current(); |
82 | 82 | } |
@@ -68,11 +68,11 @@ discard block |
||
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 |
||
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 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function save() : \Psr\Http\Message\ResponseInterface |
114 | 114 | { |
115 | - try{ |
|
115 | + try { |
|
116 | 116 | $id = $this->request->getAttribute('id'); |
117 | 117 | $user = $this->session->getStorage()->user; |
118 | 118 | $data = $this->request->getParsedBody(); |
119 | 119 | $data += (new Request())->getFiles()->toArray(); |
120 | 120 | |
121 | - if($id) { |
|
121 | + if ($id) { |
|
122 | 122 | $this->postService->updateArticle($data, $id); |
123 | 123 | } |
124 | - else{ |
|
124 | + else { |
|
125 | 125 | $this->postService->createArticle($user, $data); |
126 | 126 | } |
127 | 127 | } |
128 | - catch(FilterException $fe){ |
|
128 | + catch (FilterException $fe) { |
|
129 | 129 | return $this->edit($fe->getArrayMessages()); |
130 | 130 | } |
131 | - catch(\Exception $e){ |
|
131 | + catch (\Exception $e) { |
|
132 | 132 | throw $e; |
133 | 133 | } |
134 | 134 | |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function delete() : \Psr\Http\Message\ResponseInterface |
145 | 145 | { |
146 | - try{ |
|
146 | + try { |
|
147 | 147 | $this->postService->deleteArticle($this->request->getAttribute('id')); |
148 | 148 | } |
149 | - catch(\Exception $e){ |
|
149 | + catch (\Exception $e) { |
|
150 | 150 | throw $e; |
151 | 151 | } |
152 | 152 | |
153 | 153 | return $this->response->withStatus(302)->withHeader( |
154 | - 'Location', $this->router->generateUri('admin.posts', ['action' => 'index']) |
|
154 | + 'Location', $this->router->generateUri('admin.posts', [ 'action' => 'index' ]) |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | } |