@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | 'partial/menu-level' => __DIR__ . '/../templates/partial/menu-level.phtml', |
13 | 13 | ], |
14 | 14 | 'paths' => [ |
15 | - 'menu' => [__DIR__ . '/../templates/menu'], |
|
15 | + 'menu' => [ __DIR__ . '/../templates/menu' ], |
|
16 | 16 | ], |
17 | 17 | ], |
18 | 18 | |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | 'name' => 'admin.menu', |
34 | 34 | 'path' => '/admin/menu', |
35 | 35 | 'middleware' => Controller\IndexController::class, |
36 | - 'allowed_methods' => ['GET'], |
|
36 | + 'allowed_methods' => [ 'GET' ], |
|
37 | 37 | ], |
38 | 38 | [ |
39 | 39 | 'name' => 'admin.menu.action', |
40 | 40 | 'path' => '/admin/menu/:action/:id', |
41 | 41 | 'middleware' => Controller\IndexController::class, |
42 | - 'allowed_methods' => ['GET', 'POST'], |
|
42 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
43 | 43 | ], |
44 | 44 | ], |
45 | 45 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Admin\Controller; |
5 | 5 | |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function login($error = false): \Psr\Http\Message\ResponseInterface |
62 | 62 | { |
63 | - if($this->session->getStorage()->user) { |
|
63 | + if ($this->session->getStorage()->user) { |
|
64 | 64 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
65 | 65 | } |
66 | 66 | |
67 | - return new HtmlResponse($this->template->render('admin::login', ['layout' => false, 'error' => $error])); |
|
67 | + return new HtmlResponse($this->template->render('admin::login', [ 'layout' => false, 'error' => $error ])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function loginHandle(): \Psr\Http\Message\ResponseInterface |
76 | 76 | { |
77 | - if($this->session->getStorage()->user) { |
|
77 | + if ($this->session->getStorage()->user) { |
|
78 | 78 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $data = $this->request->getParsedBody(); |
82 | - $email = isset($data['email']) ? $data['email'] : null; |
|
83 | - $password = isset($data['password']) ? $data['password'] : null; |
|
82 | + $email = isset($data[ 'email' ]) ? $data[ 'email' ] : null; |
|
83 | + $password = isset($data[ 'password' ]) ? $data[ 'password' ] : null; |
|
84 | 84 | |
85 | 85 | try { |
86 | 86 | $this->session->getStorage()->user = $this->adminUserService->loginUser($email, $password); |
87 | 87 | |
88 | 88 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
89 | 89 | } |
90 | - catch(\Exception $e) { |
|
90 | + catch (\Exception $e) { |
|
91 | 91 | return $this->login($e->getMessage()); |
92 | 92 | |
93 | 93 | //@todo set $e->getMessage() to flash messanger and print messages in next page |
@@ -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 Admin\Controller; |
6 | 6 | |
@@ -64,12 +64,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -39,6 +39,6 @@ |
||
39 | 39 | */ |
40 | 40 | public function __invoke(Request $request, Response $response, callable $next = null) |
41 | 41 | { |
42 | - return new HtmlResponse($this->template->render('admin::index', ['layout' => 'layout/admin'])); |
|
42 | + return new HtmlResponse($this->template->render('admin::index', [ 'layout' => 'layout/admin' ])); |
|
43 | 43 | } |
44 | 44 | } |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | $allUsers = array_column($articlePosts->getAdapter()->fetchAll('select admin_user_uuid from admin_users'), 'admin_user_uuid'); |
19 | 19 | $allCategory = array_column($articlePosts->getAdapter()->fetchAll('select category_uuid from category'), 'category_uuid'); |
20 | 20 | |
21 | - for($i = 0; $i < $count; $i++) { |
|
21 | + for ($i = 0; $i < $count; $i++) { |
|
22 | 22 | // Insert Article |
23 | 23 | $id = $faker->uuid; |
24 | 24 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
25 | 25 | $title = $faker->sentence(); |
26 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
27 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
26 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
27 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
28 | 28 | $data = [ |
29 | 29 | 'article_uuid' => $mysqlUuid, |
30 | 30 | 'article_id' => $id, |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | 'title' => $title, |
47 | 47 | 'body' => $faker->paragraph(15), |
48 | 48 | 'lead' => $faker->paragraph(5), |
49 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
50 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))], |
|
49 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
50 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ], |
|
51 | 51 | 'has_layout' => true, |
52 | 52 | ]; |
53 | 53 |
@@ -6,15 +6,15 @@ |
||
6 | 6 | { |
7 | 7 | public function up() |
8 | 8 | { |
9 | - $this->table('article_posts', ['id' => false]) |
|
10 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
9 | + $this->table('article_posts', [ 'id' => false ]) |
|
10 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
11 | 11 | ->addColumn('title', 'text') |
12 | 12 | ->addColumn('body', 'text') |
13 | 13 | ->addColumn('lead', 'text') |
14 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
15 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
16 | - ->addColumn('has_layout', 'boolean', ['default' => true]) |
|
17 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
14 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
15 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
16 | + ->addColumn('has_layout', 'boolean', [ 'default' => true ]) |
|
17 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
18 | 18 | ->create(); |
19 | 19 | } |
20 | 20 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Action; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Factory\Action; |
6 | 6 |
@@ -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\Controller; |
6 | 6 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | public function index(): \Psr\Http\Message\ResponseInterface |
58 | 58 | { |
59 | 59 | $params = $this->request->getQueryParams(); |
60 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
61 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
60 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
61 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
62 | 62 | |
63 | 63 | $discussions = $this->discussionService->fetchAllArticles($page, $limit); |
64 | 64 | |
65 | - return new HtmlResponse($this->template->render('article::discussion/index', ['list' => $discussions, 'layout' => 'layout/admin'])); |
|
65 | + return new HtmlResponse($this->template->render('article::discussion/index', [ 'list' => $discussions, 'layout' => 'layout/admin' ])); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return \Psr\Http\Message\ResponseInterface |
74 | 74 | */ |
75 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
75 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
76 | 76 | { |
77 | 77 | $id = $this->request->getAttribute('id'); |
78 | 78 | $discussion = $this->discussionService->fetchSingleArticle($id); |
79 | 79 | $categories = $this->categoryService->getAll(); |
80 | 80 | |
81 | - if($this->request->getParsedBody()) { |
|
82 | - $discussion = (object)($this->request->getParsedBody() + (array)$discussion); |
|
81 | + if ($this->request->getParsedBody()) { |
|
82 | + $discussion = (object) ($this->request->getParsedBody() + (array) $discussion); |
|
83 | 83 | $discussion->article_id = $id; |
84 | 84 | } |
85 | 85 | |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | $data = $this->request->getParsedBody(); |
99 | 99 | $user = $this->session->getStorage()->user; |
100 | 100 | |
101 | - if($id) { |
|
101 | + if ($id) { |
|
102 | 102 | $this->discussionService->updateArticle($data, $id); |
103 | 103 | } else { |
104 | 104 | $this->discussionService->createArticle($user, $data); |
105 | 105 | } |
106 | 106 | } |
107 | - catch(FilterException $fe) { |
|
107 | + catch (FilterException $fe) { |
|
108 | 108 | return $this->edit($fe->getArrayMessages()); |
109 | 109 | } |
110 | - catch(\Exception $e) { |
|
110 | + catch (\Exception $e) { |
|
111 | 111 | throw $e; |
112 | 112 | } |
113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | try { |
120 | 120 | $this->discussionService->deleteArticle($this->request->getAttribute('id')); |
121 | 121 | } |
122 | - catch(\Exception $e) { |
|
122 | + catch (\Exception $e) { |
|
123 | 123 | throw $e; |
124 | 124 | } |
125 | 125 |