@@ -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 | } |
@@ -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 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | public function getCategories($articleId) |
46 | 46 | { |
47 | 47 | $select = $this->getSql()->select() |
48 | - ->columns([]) |
|
49 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['name', 'slug', 'category_id']) |
|
50 | - ->where(['articles.article_id' => $articleId]); |
|
48 | + ->columns([ ]) |
|
49 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'name', 'slug', 'category_id' ]) |
|
50 | + ->where([ 'articles.article_id' => $articleId ]); |
|
51 | 51 | |
52 | 52 | return $this->selectWith($select); |
53 | 53 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | return [ |
12 | 12 | 'templates' => [ |
13 | 13 | 'paths' => [ |
14 | - 'article' => [__DIR__ . '/../templates/article'], |
|
14 | + 'article' => [ __DIR__ . '/../templates/article' ], |
|
15 | 15 | ], |
16 | 16 | ], |
17 | 17 | |
@@ -51,49 +51,49 @@ discard block |
||
51 | 51 | 'name' => 'admin.posts', |
52 | 52 | 'path' => '/admin/posts', |
53 | 53 | 'middleware' => Controller\PostController::class, |
54 | - 'allowed_methods' => ['GET'], |
|
54 | + 'allowed_methods' => [ 'GET' ], |
|
55 | 55 | ], |
56 | 56 | [ |
57 | 57 | 'name' => 'admin.posts.action', |
58 | 58 | 'path' => '/admin/posts/:action/:id', |
59 | 59 | 'middleware' => Controller\PostController::class, |
60 | - 'allowed_methods' => ['GET', 'POST'], |
|
60 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
61 | 61 | ], |
62 | 62 | [ |
63 | 63 | 'name' => 'admin.discussions', |
64 | 64 | 'path' => '/admin/discussions', |
65 | 65 | 'middleware' => Controller\DiscussionController::class, |
66 | - 'allowed_methods' => ['GET', 'POST'] |
|
66 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
67 | 67 | ], |
68 | 68 | [ |
69 | 69 | 'name' => 'admin.discussions.action', |
70 | 70 | 'path' => '/admin/discussions/:action/:id', |
71 | 71 | 'middleware' => Controller\DiscussionController::class, |
72 | - 'allowed_methods' => ['GET', 'POST'] |
|
72 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
73 | 73 | ], |
74 | 74 | [ |
75 | 75 | 'name' => 'admin.events', |
76 | 76 | 'path' => '/admin/events', |
77 | 77 | 'middleware' => Controller\EventController::class, |
78 | - 'allowed_methods' => ['GET', 'POST'] |
|
78 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
79 | 79 | ], |
80 | 80 | [ |
81 | 81 | 'name' => 'admin.events.action', |
82 | 82 | 'path' => '/admin/events/:action/:id', |
83 | 83 | 'middleware' => Controller\EventController::class, |
84 | - 'allowed_methods' => ['GET', 'POST'] |
|
84 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
85 | 85 | ], |
86 | 86 | [ |
87 | 87 | 'name' => 'admin.videos', |
88 | 88 | 'path' => '/admin/videos', |
89 | 89 | 'middleware' => Controller\VideoController::class, |
90 | - 'allowed_methods' => ['GET', 'POST'] |
|
90 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
91 | 91 | ], |
92 | 92 | [ |
93 | 93 | 'name' => 'admin.videos.action', |
94 | 94 | 'path' => '/admin/videos/:action/:id', |
95 | 95 | 'middleware' => Controller\VideoController::class, |
96 | - 'allowed_methods' => ['GET', 'POST'] |
|
96 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
97 | 97 | ] |
98 | 98 | ], |
99 | 99 |
@@ -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\Factory\Service; |
5 | 5 | |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __invoke(ContainerInterface $container): VideoService |
23 | 23 | { |
24 | - $config = $container->get('config')['upload']; |
|
25 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
24 | + $config = $container->get('config')[ 'upload' ]; |
|
25 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
26 | 26 | |
27 | 27 | return new VideoService( |
28 | 28 | $container->get(ArticleMapper::class), |
@@ -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\Factory\Service; |
5 | 5 | |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __invoke(ContainerInterface $container): PostService |
22 | 22 | { |
23 | - $config = $container->get('config')['upload']; |
|
24 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
23 | + $config = $container->get('config')[ 'upload' ]; |
|
24 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
25 | 25 | |
26 | 26 | return new PostService( |
27 | 27 | $container->get(ArticleMapper::class), |
@@ -19,8 +19,8 @@ |
||
19 | 19 | */ |
20 | 20 | public function __invoke(ContainerInterface $container) |
21 | 21 | { |
22 | - $config = $container->get('config')['upload']; |
|
23 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
22 | + $config = $container->get('config')[ 'upload' ]; |
|
23 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
24 | 24 | |
25 | 25 | return new EventService( |
26 | 26 | $container->get(ArticleMapper::class), |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Article\Factory\Controller; |
5 | 5 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Core\Mapper; |
5 | 5 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function get($id) |
35 | 35 | { |
36 | - return $this->select(['admin_user_id' => $id])->current(); |
|
36 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getByEmail(string $email) |
46 | 46 | { |
47 | - return $this->select(['email' => $email])->current(); |
|
47 | + return $this->select([ 'email' => $email ])->current(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function updateLogin(string $userId): int |
57 | 57 | { |
58 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
58 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function getPaginationSelect($userId) |
62 | 62 | { |
63 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
63 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
64 | 64 | |
65 | 65 | $select->where->notEqualTo('admin_user_id', $userId); |
66 | 66 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function getRandom($limit) |
71 | 71 | { |
72 | 72 | $select = $this->getSql()->select() |
73 | - ->where(['status' => 1]) |
|
73 | + ->where([ 'status' => 1 ]) |
|
74 | 74 | ->order(new Expression('rand()')) |
75 | 75 | ->limit($limit); |
76 | 76 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | |
80 | 80 | public function getUuid($adminUserId) |
81 | 81 | { |
82 | - $user = $this->select(['admin_user_id' => $adminUserId])->current(); |
|
82 | + $user = $this->select([ 'admin_user_id' => $adminUserId ])->current(); |
|
83 | 83 | |
84 | - if(!$user) { |
|
84 | + if (!$user) { |
|
85 | 85 | throw new \Exception('Admin user does not exist!', 400); |
86 | 86 | } |
87 | 87 |