@@ -12,7 +12,6 @@ |
||
12 | 12 | /** |
13 | 13 | * Fetches a list of ArticleEntity models. |
14 | 14 | * |
15 | - * @param array $params |
|
16 | 15 | * @return \ArrayObject |
17 | 16 | */ |
18 | 17 | public function fetchAllArticles($page, $limit); |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Std; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface as Response; |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Std; |
4 | 4 | |
5 | 5 | class FilterException extends \Exception |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Admin; |
4 | 4 | |
5 | 5 | class ConfigProvider |
@@ -13,7 +13,7 @@ discard block |
||
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 | |
@@ -37,25 +37,25 @@ discard block |
||
37 | 37 | 'name' => 'auth', |
38 | 38 | 'path' => '/auth/:action', |
39 | 39 | 'middleware' => Controller\AuthController::class, |
40 | - 'allowed_methods' => ['GET', 'POST'], |
|
40 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
41 | 41 | ], |
42 | 42 | [ |
43 | 43 | 'name' => 'admin', |
44 | 44 | 'path' => '/admin', |
45 | 45 | 'middleware' => Action\IndexAction::class, |
46 | - 'allowed_methods' => ['GET'], |
|
46 | + 'allowed_methods' => [ 'GET' ], |
|
47 | 47 | ], |
48 | 48 | [ |
49 | 49 | 'name' => 'admin.users', |
50 | 50 | 'path' => '/admin/users', |
51 | 51 | 'middleware' => Controller\UserController::class, |
52 | - 'allowed_methods' => ['GET'] |
|
52 | + 'allowed_methods' => [ 'GET' ] |
|
53 | 53 | ], |
54 | 54 | [ |
55 | 55 | 'name' => 'admin.users.action', |
56 | 56 | 'path' => '/admin/users/:action/:id', |
57 | 57 | 'middleware' => Controller\UserController::class, |
58 | - 'allowed_methods' => ['GET', 'POST'] |
|
58 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
59 | 59 | ], |
60 | 60 | ], |
61 | 61 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'middleware_pipeline' => [ |
70 | 70 | // execute this middleware on every /admin[*] path |
71 | 71 | 'permission' => [ |
72 | - 'middleware' => [Middleware\AdminAuth::class], |
|
72 | + 'middleware' => [ Middleware\AdminAuth::class ], |
|
73 | 73 | 'priority' => 100, |
74 | 74 | 'path' => '/admin' |
75 | 75 | ], |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | { |
68 | 68 | $user = $this->session->getStorage()->user; |
69 | 69 | $params = $this->request->getQueryParams(); |
70 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
71 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
70 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
71 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
72 | 72 | |
73 | 73 | $adminUsers = $this->adminUserService->getPagination($page, $limit, $user->admin_user_id); |
74 | 74 | |
75 | 75 | return new HtmlResponse($this->template->render( |
76 | 76 | 'admin::user/index', |
77 | - ['list' => $adminUsers, 'layout' => 'layout/admin']) |
|
77 | + [ 'list' => $adminUsers, 'layout' => 'layout/admin' ]) |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return \Psr\Http\Message\ResponseInterface |
85 | 85 | */ |
86 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
86 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
87 | 87 | { |
88 | 88 | $id = $this->request->getAttribute('id'); |
89 | 89 | $user = $this->adminUserService->getUser($id); |
90 | 90 | |
91 | 91 | if ($this->request->getParsedBody()) { |
92 | - $user = (object)($this->request->getParsedBody() + (array)$user); |
|
92 | + $user = (object) ($this->request->getParsedBody() + (array) $user); |
|
93 | 93 | $user->admin_user_id = $id; |
94 | 94 | } |
95 | 95 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
69 | 69 | } |
70 | 70 | |
71 | - return new HtmlResponse($this->template->render('admin::login', ['layout' => false, 'error' => $error])); |
|
71 | + return new HtmlResponse($this->template->render('admin::login', [ 'layout' => false, 'error' => $error ])); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | $data = $this->request->getParsedBody(); |
86 | - $email = isset($data['email']) ? $data['email'] : null; |
|
87 | - $password = isset($data['password']) ? $data['password'] : null; |
|
86 | + $email = isset($data[ 'email' ]) ? $data[ 'email' ] : null; |
|
87 | + $password = isset($data[ 'password' ]) ? $data[ 'password' ] : null; |
|
88 | 88 | |
89 | 89 | try { |
90 | 90 | $this->session->getStorage()->user = $this->adminUserService->loginUser($email, $password); |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | 'profile_img' => $this->upload->uploadImage($data, 'profile_img') |
135 | 135 | ]; |
136 | 136 | |
137 | - unset($data['confirm_password']); |
|
138 | - $data['password'] = $this->crypt->create($data['password']); |
|
139 | - $data['admin_user_id'] = Uuid::uuid1()->toString(); |
|
140 | - $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary); |
|
137 | + unset($data[ 'confirm_password' ]); |
|
138 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
139 | + $data[ 'admin_user_id' ] = Uuid::uuid1()->toString(); |
|
140 | + $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary); |
|
141 | 141 | |
142 | 142 | return $this->adminUsersMapper->insert($data); |
143 | 143 | } |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
152 | 152 | |
153 | 153 | // we dont want to force user to enter the password again |
154 | - if ($data['password'] == '') { |
|
154 | + if ($data[ 'password' ] == '') { |
|
155 | 155 | $filter->remove('password'); |
156 | 156 | $filter->remove('confirm_password'); |
157 | 157 | } |
158 | 158 | |
159 | 159 | // if we want to keep same email |
160 | - if ($user->email == $data['email']) { |
|
160 | + if ($user->email == $data[ 'email' ]) { |
|
161 | 161 | $filter->remove('email'); |
162 | 162 | } |
163 | 163 | |
@@ -171,24 +171,24 @@ discard block |
||
171 | 171 | ]; |
172 | 172 | |
173 | 173 | // We don't want to force user to re-upload image on edit |
174 | - if (!$data['face_img']) { |
|
175 | - unset($data['face_img']); |
|
174 | + if (!$data[ 'face_img' ]) { |
|
175 | + unset($data[ 'face_img' ]); |
|
176 | 176 | } else { |
177 | 177 | $this->upload->deleteFile($user->face_img); |
178 | 178 | } |
179 | 179 | |
180 | - if (!$data['profile_img']) { |
|
181 | - unset($data['profile_img']); |
|
180 | + if (!$data[ 'profile_img' ]) { |
|
181 | + unset($data[ 'profile_img' ]); |
|
182 | 182 | } else { |
183 | 183 | $this->upload->deleteFile($user->profile_img); |
184 | 184 | } |
185 | 185 | |
186 | - if (isset($data['password'])) { |
|
187 | - unset($data['confirm_password']); |
|
188 | - $data['password'] = $this->crypt->create($data['password']); |
|
186 | + if (isset($data[ 'password' ])) { |
|
187 | + unset($data[ 'confirm_password' ]); |
|
188 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
189 | 189 | } |
190 | 190 | |
191 | - return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]); |
|
191 | + return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $this->upload->deleteFile($adminUser->face_img); |
208 | 208 | $this->upload->deleteFile($adminUser->profile_img); |
209 | 209 | |
210 | - return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]); |
|
210 | + return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | [ |
27 | 27 | 'name' => 'first_name', |
28 | 28 | 'required' => true, |
29 | - 'filters' => [['name' => 'StringTrim']], |
|
29 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
30 | 30 | 'validators' => [ |
31 | - ['name' => 'NotEmpty'], |
|
32 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]] |
|
31 | + [ 'name' => 'NotEmpty' ], |
|
32 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ] |
|
33 | 33 | ], |
34 | 34 | ] |
35 | 35 | ); |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | [ |
39 | 39 | 'name' => 'last_name', |
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' => 255]] |
|
43 | + [ 'name' => 'NotEmpty' ], |
|
44 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ] |
|
45 | 45 | ], |
46 | 46 | ] |
47 | 47 | ); |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | [ |
51 | 51 | 'name' => 'email', |
52 | 52 | 'required' => true, |
53 | - 'filters' => [['name' => 'StringTrim']], |
|
53 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
54 | 54 | 'validators' => [ |
55 | - ['name' => 'NotEmpty'], |
|
56 | - ['name' => 'EmailAddress'], |
|
55 | + [ 'name' => 'NotEmpty' ], |
|
56 | + [ 'name' => 'EmailAddress' ], |
|
57 | 57 | [ |
58 | 58 | 'name' => 'dbnorecordexists', |
59 | - 'options' => ['adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email'] |
|
59 | + 'options' => [ 'adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email' ] |
|
60 | 60 | ], |
61 | 61 | ], |
62 | 62 | ] |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | [ |
67 | 67 | 'name' => 'introduction', |
68 | 68 | 'required' => false, |
69 | - 'filters' => [['name' => 'StringTrim']] |
|
69 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
70 | 70 | ] |
71 | 71 | ); |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | [ |
75 | 75 | 'name' => 'biography', |
76 | 76 | 'required' => false, |
77 | - 'filters' => [['name' => 'StringTrim']] |
|
77 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
78 | 78 | ] |
79 | 79 | ); |
80 | 80 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | 'name' => 'password', |
84 | 84 | 'required' => true, |
85 | 85 | 'validators' => [ |
86 | - ['name' => 'NotEmpty'], |
|
87 | - ['name' => 'StringLength', 'options' => ['min' => 7, 'max' => 255]] |
|
86 | + [ 'name' => 'NotEmpty' ], |
|
87 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 7, 'max' => 255 ] ] |
|
88 | 88 | ], |
89 | 89 | ] |
90 | 90 | ); |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | 'name' => 'confirm_password', |
95 | 95 | 'required' => true, |
96 | 96 | 'validators' => [ |
97 | - ['name' => 'NotEmpty'], |
|
98 | - ['name' => 'Identical', 'options' => ['token' => 'password']], |
|
97 | + [ 'name' => 'NotEmpty' ], |
|
98 | + [ 'name' => 'Identical', 'options' => [ 'token' => 'password' ] ], |
|
99 | 99 | ], |
100 | 100 | ] |
101 | 101 | ); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | [ |
105 | 105 | 'name' => 'status', |
106 | 106 | 'required' => true, |
107 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Digits']] |
|
107 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Digits' ] ] |
|
108 | 108 | ] |
109 | 109 | ); |
110 | 110 |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | ->join( |
37 | 37 | 'articles', |
38 | 38 | 'article_videos.article_uuid = articles.article_uuid', |
39 | - ['slug', 'published_at', 'status', 'article_id'] |
|
39 | + [ 'slug', 'published_at', 'status', 'article_id' ] |
|
40 | 40 | )->join( |
41 | 41 | 'admin_users', |
42 | 42 | 'admin_users.admin_user_uuid = articles.admin_user_uuid', |
43 | - ['admin_user_id', 'first_name', 'last_name'] |
|
44 | - )->where(['articles.type' => ArticleType::VIDEO]) |
|
45 | - ->order(['articles.created_at' => 'desc']); |
|
43 | + [ 'admin_user_id', 'first_name', 'last_name' ] |
|
44 | + )->where([ 'articles.type' => ArticleType::VIDEO ]) |
|
45 | + ->order([ 'articles.created_at' => 'desc' ]); |
|
46 | 46 | |
47 | 47 | if ($isActive !== null) { |
48 | - $select->where(['articles.status' => (int)$isActive]); |
|
48 | + $select->where([ 'articles.status' => (int) $isActive ]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $select; |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | public function get($id) |
55 | 55 | { |
56 | 56 | $select = $this->getSql()->select() |
57 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title']) |
|
57 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title' ]) |
|
58 | 58 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
59 | 59 | ->join( |
60 | 60 | 'category', 'category.category_uuid = articles.category_uuid', |
61 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
61 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
62 | 62 | ) |
63 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
64 | - ->where(['articles.article_id' => $id]); |
|
63 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
64 | + ->where([ 'articles.article_id' => $id ]); |
|
65 | 65 | |
66 | 66 | return $this->selectWith($select)->current(); |
67 | 67 | } |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | $select = $this->getSql()->select() |
72 | 72 | ->join( |
73 | 73 | 'articles', |
74 | - 'article_videos.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at'] |
|
75 | - )->where(['articles.status' => 1]) |
|
76 | - ->order(['published_at' => 'desc']) |
|
74 | + 'article_videos.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ] |
|
75 | + )->where([ 'articles.status' => 1 ]) |
|
76 | + ->order([ 'published_at' => 'desc' ]) |
|
77 | 77 | ->limit($limit); |
78 | 78 | |
79 | 79 | return $this->selectWith($select); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $select = $this->getSql()->select() |
85 | 85 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
86 | - ->where(['articles.slug' => $slug]); |
|
86 | + ->where([ 'articles.slug' => $slug ]); |
|
87 | 87 | |
88 | 88 | return $this->selectWith($select)->current(); |
89 | 89 | } |