@@ -7,9 +7,9 @@ |
||
7 | 7 | |
8 | 8 | public function change() |
9 | 9 | { |
10 | - $this->table('newsletter', ['id' => false]) |
|
10 | + $this->table('newsletter', [ 'id' => false ]) |
|
11 | 11 | ->addColumn('email', 'text') |
12 | - ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP']) |
|
12 | + ->addColumn('created_at', 'timestamp', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
13 | 13 | ->create(); |
14 | 14 | } |
15 | 15 | } |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | $allUsers = array_column($articleEvents->getAdapter()->fetchAll('select admin_user_uuid from admin_users'), 'admin_user_uuid'); |
19 | 19 | $allCategory = array_column($articleEvents->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, |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | 'start_at' => $faker->dateTimeBetween('now', '+5 days')->format('Y-m-d H:i:s'), |
53 | 53 | 'end_at' => $faker->dateTimeBetween('+5 days', '+6 days')->format('Y-m-d H:i:s'), |
54 | 54 | 'event_url' => 'https://www.meetup.com/Tokyo-Hello-Kitty-Meetup/', |
55 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
56 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))] |
|
55 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
56 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ] |
|
57 | 57 | ]; |
58 | 58 | |
59 | 59 | $articleEvents->insert($data)->save(); |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function getImages($faker, $type = 'people', $width = 400, $height = 400) |
13 | 13 | { |
14 | - $images = []; |
|
14 | + $images = [ ]; |
|
15 | 15 | $conf = include __DIR__ . "/../../../config/autoload/local.php"; |
16 | - $p = $conf['upload']['public_path']; |
|
16 | + $p = $conf[ 'upload' ][ 'public_path' ]; |
|
17 | 17 | $upload = new Upload($p, ''); |
18 | 18 | |
19 | - for($i = 0; $i < 5; $i++) { |
|
19 | + for ($i = 0; $i < 5; $i++) { |
|
20 | 20 | $filename = md5(rand()) . '.jpg'; |
21 | - $path = $p . $filename[0] . '/' . $filename[1] . '/' . $filename[2] . '/' . $filename; |
|
21 | + $path = $p . $filename[ 0 ] . '/' . $filename[ 1 ] . '/' . $filename[ 2 ] . '/' . $filename; |
|
22 | 22 | $upload->getPath($filename); // create sub folders |
23 | 23 | $img = file_get_contents($faker->imageUrl(400, 400, $type)); |
24 | 24 | file_put_contents($path, $img); |
25 | 25 | |
26 | - $images[] = $upload->getWebPath($filename); |
|
26 | + $images[ ] = $upload->getWebPath($filename); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return $images; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $faceImages = $this->getImages($faker, 'people'); |
38 | 38 | $profileImages = $this->getImages($faker, 'fashion'); |
39 | 39 | |
40 | - for($i = 0; $i < $count; $i++) { |
|
40 | + for ($i = 0; $i < $count; $i++) { |
|
41 | 41 | $id = $faker->uuid; |
42 | 42 | $mysqluuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
43 | 43 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'status' => rand(0, 1), |
52 | 52 | 'last_login' => rand(0, 10) === 7 ? null : $faker->dateTimeBetween('-10 days', 'now')->format('Y-m-d H:i:s'), |
53 | 53 | 'created_at' => $faker->dateTimeBetween('-20 days', '-10 days')->format('Y-m-d H:i:s'), |
54 | - 'face_img' => $faceImages[rand(0, (count($faceImages) - 1))], |
|
55 | - 'profile_img' => $profileImages[rand(0, (count($profileImages) - 1))] |
|
54 | + 'face_img' => $faceImages[ rand(0, (count($faceImages) - 1)) ], |
|
55 | + 'profile_img' => $profileImages[ rand(0, (count($profileImages) - 1)) ] |
|
56 | 56 | ]; |
57 | 57 | |
58 | 58 | $users->insert($data)->save(); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | $category = $this->table('category'); |
12 | 12 | $count = rand(5, 10); |
13 | 13 | |
14 | - for($i = 0; $i < $count; $i++) { |
|
14 | + for ($i = 0; $i < $count; $i++) { |
|
15 | 15 | $id = $faker->uuid; |
16 | 16 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
17 | 17 | $categoryName = $faker->name; |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | $allUsers = array_column($articleVideos->getAdapter()->fetchAll('select admin_user_uuid from admin_users'), 'admin_user_uuid'); |
27 | 27 | $allCategory = array_column($articleVideos->getAdapter()->fetchAll('select category_uuid from category'), 'category_uuid'); |
28 | 28 | |
29 | - for($i = 0; $i < $count; $i++) { |
|
29 | + for ($i = 0; $i < $count; $i++) { |
|
30 | 30 | // Insert Article |
31 | 31 | $id = $faker->uuid; |
32 | 32 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
33 | 33 | $title = $faker->sentence(); |
34 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
35 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
34 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
35 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
36 | 36 | $data = [ |
37 | 37 | 'article_uuid' => $mysqlUuid, |
38 | 38 | 'article_id' => $id, |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | 'sub_title' => $faker->sentence(), |
57 | 57 | 'body' => $faker->paragraph(30), |
58 | 58 | 'lead' => $faker->paragraph(5), |
59 | - 'video_url' => self::VIDEOS[rand(0, (count(self::VIDEOS) - 1))], |
|
60 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
61 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))] |
|
59 | + 'video_url' => self::VIDEOS[ rand(0, (count(self::VIDEOS) - 1)) ], |
|
60 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
61 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ] |
|
62 | 62 | ]; |
63 | 63 | |
64 | 64 | $articleVideos->insert($data)->save(); |
@@ -8,21 +8,21 @@ discard block |
||
8 | 8 | { |
9 | 9 | public function up() |
10 | 10 | { |
11 | - $this->table('admin_users', ['id' => false, 'primary_key' => 'admin_user_uuid']) |
|
12 | - ->addColumn('admin_user_uuid', 'binary', ['limit' => 16]) |
|
11 | + $this->table('admin_users', [ 'id' => false, 'primary_key' => 'admin_user_uuid' ]) |
|
12 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
13 | 13 | ->addColumn('admin_user_id', 'text') |
14 | 14 | ->addColumn('first_name', 'text') |
15 | 15 | ->addColumn('last_name', 'text') |
16 | - ->addColumn('introduction', 'text', ['null' => true]) |
|
17 | - ->addColumn('biography', 'text', ['null' => true]) |
|
18 | - ->addColumn('email', 'string', ['limit' => 128]) |
|
19 | - ->addColumn('password', 'char', ['limit' => 60]) |
|
20 | - ->addColumn('status', 'integer', ['default' => 0])// 0 => not active, 1 = active |
|
21 | - ->addColumn('face_img', 'text', ['null' => true]) |
|
22 | - ->addColumn('profile_img', 'text', ['null' => true]) |
|
23 | - ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
24 | - ->addColumn('last_login', 'datetime', ['null' => true]) |
|
25 | - ->addIndex(['email'], ['name' => 'email_INDEX']) |
|
16 | + ->addColumn('introduction', 'text', [ 'null' => true ]) |
|
17 | + ->addColumn('biography', 'text', [ 'null' => true ]) |
|
18 | + ->addColumn('email', 'string', [ 'limit' => 128 ]) |
|
19 | + ->addColumn('password', 'char', [ 'limit' => 60 ]) |
|
20 | + ->addColumn('status', 'integer', [ 'default' => 0 ])// 0 => not active, 1 = active |
|
21 | + ->addColumn('face_img', 'text', [ 'null' => true ]) |
|
22 | + ->addColumn('profile_img', 'text', [ 'null' => true ]) |
|
23 | + ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
24 | + ->addColumn('last_login', 'datetime', [ 'null' => true ]) |
|
25 | + ->addIndex([ 'email' ], [ 'name' => 'email_INDEX' ]) |
|
26 | 26 | ->create(); |
27 | 27 | |
28 | 28 | // Insert one default admin user with password testtest |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | private function getImage($faker, $type = 'people', $width = 400, $height = 400) |
52 | 52 | { |
53 | 53 | $conf = include __DIR__ . "/../../../config/autoload/local.php"; |
54 | - $p = $conf['upload']['public_path']; |
|
54 | + $p = $conf[ 'upload' ][ 'public_path' ]; |
|
55 | 55 | $upload = new \UploadHelper\Upload($p, ''); |
56 | 56 | $filename = md5(rand()) . '.jpg'; |
57 | - $path = $p . $filename[0] . '/' . $filename[1] . '/' . $filename[2] . '/' . $filename; |
|
57 | + $path = $p . $filename[ 0 ] . '/' . $filename[ 1 ] . '/' . $filename[ 2 ] . '/' . $filename; |
|
58 | 58 | $upload->getPath($filename); // create sub folders |
59 | 59 | $img = file_get_contents($faker->imageUrl(400, 400, $type)); |
60 | 60 | file_put_contents($path, $img); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
54 | 54 | $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data); |
55 | 55 | |
56 | - if(!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
56 | + if (!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
57 | 57 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
58 | 58 | } |
59 | 59 | |
@@ -62,16 +62,16 @@ discard block |
||
62 | 62 | |
63 | 63 | $article = $articleFilter->getValues(); |
64 | 64 | $article += [ |
65 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
65 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
66 | 66 | 'type' => ArticleType::DISCUSSION, |
67 | 67 | 'article_id' => $id, |
68 | 68 | 'article_uuid' => $uuId |
69 | 69 | ]; |
70 | 70 | |
71 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
72 | - unset($article['category_id'], $article['admin_user_id']); |
|
71 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
72 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
73 | 73 | |
74 | - $discussion = $discussionFilter->getValues() + ['article_uuid' => $uuId]; |
|
74 | + $discussion = $discussionFilter->getValues() + [ 'article_uuid' => $uuId ]; |
|
75 | 75 | |
76 | 76 | $this->articleMapper->insert($article); |
77 | 77 | $this->articleDiscussionsMapper->insert($discussion); |
@@ -83,30 +83,30 @@ discard block |
||
83 | 83 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
84 | 84 | $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data); |
85 | 85 | |
86 | - if(!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
86 | + if (!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
87 | 87 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
88 | 88 | } |
89 | 89 | |
90 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
90 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
91 | 91 | $discussion = $discussionFilter->getValues(); |
92 | 92 | |
93 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
94 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
95 | - unset($article['category_id'], $article['admin_user_id']); |
|
93 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
94 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
95 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
96 | 96 | |
97 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
98 | - $this->articleDiscussionsMapper->update($discussion, ['article_uuid' => $article['article_uuid']]); |
|
97 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
98 | + $this->articleDiscussionsMapper->update($discussion, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | public function deleteArticle($id) |
102 | 102 | { |
103 | 103 | $discussion = $this->articleDiscussionsMapper->get($id); |
104 | 104 | |
105 | - if(!$discussion) { |
|
105 | + if (!$discussion) { |
|
106 | 106 | throw new \Exception('Article not found!'); |
107 | 107 | } |
108 | 108 | |
109 | - $this->articleDiscussionsMapper->delete(['article_uuid' => $discussion->article_uuid]); |
|
109 | + $this->articleDiscussionsMapper->delete([ 'article_uuid' => $discussion->article_uuid ]); |
|
110 | 110 | $this->delete($discussion->article_uuid); |
111 | 111 | } |
112 | 112 | } |
@@ -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 | |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | public function index(): \Psr\Http\Message\ResponseInterface |
35 | 35 | { |
36 | 36 | $params = $this->request->getQueryParams(); |
37 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
38 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
37 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
38 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
39 | 39 | $events = $this->eventService->fetchAllArticles($page, $limit); |
40 | 40 | |
41 | - return new HtmlResponse($this->template->render('article::event/index', ['list' => $events, 'layout' => 'layout/admin'])); |
|
41 | + return new HtmlResponse($this->template->render('article::event/index', [ 'list' => $events, 'layout' => 'layout/admin' ])); |
|
42 | 42 | } |
43 | 43 | |
44 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
44 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
45 | 45 | { |
46 | 46 | $id = $this->request->getAttribute('id'); |
47 | 47 | $event = $this->eventService->fetchSingleArticle($id); |
48 | 48 | $categories = $this->categoryService->getAll(); |
49 | 49 | |
50 | - if($this->request->getParsedBody()) { |
|
51 | - $event = (object)($this->request->getParsedBody() + (array)$event); |
|
50 | + if ($this->request->getParsedBody()) { |
|
51 | + $event = (object) ($this->request->getParsedBody() + (array) $event); |
|
52 | 52 | $event->article_id = $id; |
53 | 53 | } |
54 | 54 | |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $data = $this->request->getParsedBody(); |
69 | 69 | $data += (new Request())->getFiles()->toArray(); |
70 | 70 | |
71 | - if($id) { |
|
71 | + if ($id) { |
|
72 | 72 | $this->eventService->updateArticle($data, $id); |
73 | 73 | } else { |
74 | 74 | $this->eventService->createArticle($user, $data); |
75 | 75 | } |
76 | 76 | } |
77 | - catch(FilterException $fe) { |
|
77 | + catch (FilterException $fe) { |
|
78 | 78 | return $this->edit($fe->getArrayMessages()); |
79 | 79 | } |
80 | - catch(\Exception $e) { |
|
80 | + catch (\Exception $e) { |
|
81 | 81 | throw $e; |
82 | 82 | } |
83 | 83 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | try { |
90 | 90 | $this->eventService->deleteArticle($this->request->getAttribute('id')); |
91 | 91 | } |
92 | - catch(\Exception $e) { |
|
92 | + catch (\Exception $e) { |
|
93 | 93 | throw $e; |
94 | 94 | } |
95 | 95 |
@@ -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 | |
@@ -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 | $videos = $this->videoService->fetchAllArticles($page, $limit); |
74 | 74 | |
75 | - return new HtmlResponse($this->template->render('article::video/index', ['list' => $videos, 'layout' => 'layout/admin'])); |
|
75 | + return new HtmlResponse($this->template->render('article::video/index', [ 'list' => $videos, 'layout' => 'layout/admin' ])); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return \Psr\Http\Message\ResponseInterface |
82 | 82 | */ |
83 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
83 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
84 | 84 | { |
85 | 85 | $id = $this->request->getAttribute('id'); |
86 | 86 | $video = $this->videoService->fetchSingleArticle($id); |
87 | 87 | $categories = $this->categoryService->getAll(); |
88 | 88 | |
89 | - if($this->request->getParsedBody()) { |
|
90 | - $video = (object)($this->request->getParsedBody() + (array)$video); |
|
89 | + if ($this->request->getParsedBody()) { |
|
90 | + $video = (object) ($this->request->getParsedBody() + (array) $video); |
|
91 | 91 | $video->article_id = $id; |
92 | 92 | } |
93 | 93 | |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | $data = $this->request->getParsedBody(); |
115 | 115 | $data += (new Request())->getFiles()->toArray(); |
116 | 116 | |
117 | - if($id) { |
|
117 | + if ($id) { |
|
118 | 118 | $this->videoService->updateArticle($data, $id); |
119 | 119 | } else { |
120 | 120 | $this->videoService->createArticle($user, $data); |
121 | 121 | } |
122 | 122 | } |
123 | - catch(FilterException $fe) { |
|
123 | + catch (FilterException $fe) { |
|
124 | 124 | return $this->edit($fe->getArrayMessages()); |
125 | 125 | } |
126 | - catch(\Exception $e) { |
|
126 | + catch (\Exception $e) { |
|
127 | 127 | throw $e; |
128 | 128 | } |
129 | 129 | |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | try { |
142 | 142 | $this->videoService->deleteArticle($this->request->getAttribute('id')); |
143 | 143 | } |
144 | - catch(\Exception $e) { |
|
144 | + catch (\Exception $e) { |
|
145 | 145 | throw $e; |
146 | 146 | } |
147 | 147 | |
148 | 148 | return $this->response->withStatus(302)->withHeader( |
149 | - 'Location', $this->router->generateUri('admin.videos', ['action' => 'index']) |
|
149 | + 'Location', $this->router->generateUri('admin.videos', [ 'action' => 'index' ]) |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | } |