@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | public function getPaginationSelect() |
34 | 34 | { |
35 | 35 | return $this->getSql()->select() |
36 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
36 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
37 | 37 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
38 | - ->join('category', 'articles.category_uuid = category.category_uuid', ['category_name' => 'name'], 'left') |
|
39 | - ->where(['articles.type' => ArticleType::POST]) |
|
40 | - ->order(['created_at' => 'desc']); |
|
38 | + ->join('category', 'articles.category_uuid = category.category_uuid', [ 'category_name' => 'name' ], 'left') |
|
39 | + ->where([ 'articles.type' => ArticleType::POST ]) |
|
40 | + ->order([ 'created_at' => 'desc' ]); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function get($id) |
44 | 44 | { |
45 | 45 | $select = $this->getSql()->select() |
46 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout']) |
|
46 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout' ]) |
|
47 | 47 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
48 | 48 | ->join( |
49 | 49 | 'category', 'category.category_uuid = articles.category_uuid', |
50 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
50 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
51 | 51 | ) |
52 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
53 | - ->where(['articles.article_id' => $id]); |
|
52 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
53 | + ->where([ 'articles.article_id' => $id ]); |
|
54 | 54 | |
55 | 55 | return $this->selectWith($select)->current(); |
56 | 56 | } |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | { |
60 | 60 | $select = $this->getSql()->select() |
61 | 61 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
62 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_slug' => 'slug']) |
|
63 | - ->where(['articles.status' => 1]) |
|
62 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_slug' => 'slug' ]) |
|
63 | + ->where([ 'articles.status' => 1 ]) |
|
64 | 64 | ->limit(1); |
65 | 65 | |
66 | 66 | if ($direction > 0) { |
67 | 67 | $select->where->greaterThan('published_at', $publishedAt); |
68 | - $select->order(['published_at' => 'asc']); |
|
68 | + $select->order([ 'published_at' => 'asc' ]); |
|
69 | 69 | } elseif ($direction < 0) { |
70 | 70 | $select->where->lessThan('published_at', $publishedAt); |
71 | - $select->order(['published_at' => 'desc']); |
|
71 | + $select->order([ 'published_at' => 'desc' ]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $this->selectWith($select)->current(); |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | public function getBySlug($slug) |
78 | 78 | { |
79 | 79 | $select = $this->getSql()->select() |
80 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
80 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
81 | 81 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
82 | 82 | ->join( |
83 | 83 | 'category', |
84 | 84 | 'category.category_uuid = articles.category_uuid', |
85 | - ['category_name' => 'name', 'category_slug' => 'slug'] |
|
85 | + [ 'category_name' => 'name', 'category_slug' => 'slug' ] |
|
86 | 86 | )->join( |
87 | 87 | 'admin_users', |
88 | 88 | 'admin_users.admin_user_uuid = articles.admin_user_uuid', |
89 | - ['first_name', 'last_name']) |
|
90 | - ->where(['articles.slug' => $slug, 'articles.status' => 1]); |
|
89 | + [ 'first_name', 'last_name' ]) |
|
90 | + ->where([ 'articles.slug' => $slug, 'articles.status' => 1 ]); |
|
91 | 91 | |
92 | 92 | return $this->selectWith($select)->current(); |
93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function getAll() |
96 | 96 | { |
97 | 97 | $select = $this->getSql()->select() |
98 | - ->join('articles', 'article_posts.article_uuid = articles.article_uuid', ['article_id', 'slug']); |
|
98 | + ->join('articles', 'article_posts.article_uuid = articles.article_uuid', [ 'article_id', 'slug' ]); |
|
99 | 99 | |
100 | 100 | return $this->selectWith($select); |
101 | 101 | } |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | { |
105 | 105 | $select = $this->getSql()->select() |
106 | 106 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
107 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
107 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
108 | 108 | ->join( |
109 | 109 | 'category', 'category.category_uuid = articles.category_uuid', |
110 | - ['category_name' => 'name', 'category_id', 'category_slug' => 'slug'] |
|
110 | + [ 'category_name' => 'name', 'category_id', 'category_slug' => 'slug' ] |
|
111 | 111 | ) |
112 | - ->where(['articles.status' => 1]) |
|
113 | - ->order(['articles.published_at' => 'desc']) |
|
112 | + ->where([ 'articles.status' => 1 ]) |
|
113 | + ->order([ 'articles.published_at' => 'desc' ]) |
|
114 | 114 | ->limit($limit); |
115 | 115 | |
116 | 116 | return $this->selectWith($select); |
@@ -22,23 +22,23 @@ |
||
22 | 22 | public function getPaginationSelect() |
23 | 23 | { |
24 | 24 | return $this->getSql()->select() |
25 | - ->columns(['title', 'body']) |
|
25 | + ->columns([ 'title', 'body' ]) |
|
26 | 26 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
27 | - ->where(['articles.type' => ArticleType::DISCUSSION]) |
|
28 | - ->order(['created_at' => 'desc']); |
|
27 | + ->where([ 'articles.type' => ArticleType::DISCUSSION ]) |
|
28 | + ->order([ 'created_at' => 'desc' ]); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function get($id) |
32 | 32 | { |
33 | 33 | $select = $this->getSql()->select() |
34 | - ->columns(['title', 'body']) |
|
34 | + ->columns([ 'title', 'body' ]) |
|
35 | 35 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
36 | 36 | ->join( |
37 | 37 | 'category', 'category.category_uuid = articles.category_uuid', |
38 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
38 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
39 | 39 | ) |
40 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
41 | - ->where(['articles.article_id' => $id]); |
|
40 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
41 | + ->where([ 'articles.article_id' => $id ]); |
|
42 | 42 | |
43 | 43 | return $this->selectWith($select)->current(); |
44 | 44 | } |
@@ -45,24 +45,24 @@ |
||
45 | 45 | public function index(): \Psr\Http\Message\ResponseInterface |
46 | 46 | { |
47 | 47 | $params = $this->request->getQueryParams(); |
48 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
49 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
48 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
49 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
50 | 50 | $events = $this->eventService->fetchAllArticles($page, $limit); |
51 | 51 | |
52 | 52 | return new HtmlResponse($this->template->render( |
53 | 53 | 'article::event/index', |
54 | - ['list' => $events, 'layout' => 'layout/admin']) |
|
54 | + [ 'list' => $events, 'layout' => 'layout/admin' ]) |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
58 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
59 | 59 | { |
60 | 60 | $id = $this->request->getAttribute('id'); |
61 | 61 | $event = $this->eventService->fetchSingleArticle($id); |
62 | 62 | $categories = $this->categoryService->getAll(); |
63 | 63 | |
64 | 64 | if ($this->request->getParsedBody()) { |
65 | - $event = (object)($this->request->getParsedBody() + (array)$event); |
|
65 | + $event = (object) ($this->request->getParsedBody() + (array) $event); |
|
66 | 66 | $event->article_id = $id; |
67 | 67 | } |
68 | 68 |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | public function index(): HtmlResponse |
67 | 67 | { |
68 | 68 | $params = $this->request->getQueryParams(); |
69 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
70 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
69 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
70 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
71 | 71 | $videos = $this->videoService->fetchAllArticles($page, $limit); |
72 | 72 | |
73 | 73 | return new HtmlResponse($this->template->render( |
74 | 74 | 'article::video/index', |
75 | - ['list' => $videos, 'layout' => 'layout/admin']) |
|
75 | + [ 'list' => $videos, 'layout' => 'layout/admin' ]) |
|
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return \Psr\Http\Message\ResponseInterface |
83 | 83 | */ |
84 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
84 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
85 | 85 | { |
86 | 86 | $id = $this->request->getAttribute('id'); |
87 | 87 | $video = $this->videoService->fetchSingleArticle($id); |
88 | 88 | $categories = $this->categoryService->getAll(); |
89 | 89 | |
90 | 90 | if ($this->request->getParsedBody()) { |
91 | - $video = (object)($this->request->getParsedBody() + (array)$video); |
|
91 | + $video = (object) ($this->request->getParsedBody() + (array) $video); |
|
92 | 92 | $video->article_id = $id; |
93 | 93 | } |
94 | 94 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | return $this->response->withStatus(302)->withHeader( |
151 | - 'Location', $this->router->generateUri('admin.videos', ['action' => 'index']) |
|
151 | + 'Location', $this->router->generateUri('admin.videos', [ 'action' => 'index' ]) |
|
152 | 152 | ); |
153 | 153 | } |
154 | 154 | } |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | public function index(): \Psr\Http\Message\ResponseInterface |
70 | 70 | { |
71 | 71 | $params = $this->request->getQueryParams(); |
72 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
73 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
72 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
73 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
74 | 74 | |
75 | 75 | $discussions = $this->discussionService->fetchAllArticles($page, $limit); |
76 | 76 | |
77 | 77 | return new HtmlResponse($this->template->render( |
78 | 78 | 'article::discussion/index', |
79 | - ['list' => $discussions, 'layout' => 'layout/admin']) |
|
79 | + [ 'list' => $discussions, 'layout' => 'layout/admin' ]) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return \Psr\Http\Message\ResponseInterface |
89 | 89 | */ |
90 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
90 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
91 | 91 | { |
92 | 92 | $id = $this->request->getAttribute('id'); |
93 | 93 | $discussion = $this->discussionService->fetchSingleArticle($id); |
94 | 94 | $categories = $this->categoryService->getAll(); |
95 | 95 | |
96 | 96 | if ($this->request->getParsedBody()) { |
97 | - $discussion = (object)($this->request->getParsedBody() + (array)$discussion); |
|
97 | + $discussion = (object) ($this->request->getParsedBody() + (array) $discussion); |
|
98 | 98 | $discussion->article_id = $id; |
99 | 99 | } |
100 | 100 |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | public function index(): HtmlResponse |
67 | 67 | { |
68 | 68 | $params = $this->request->getQueryParams(); |
69 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
70 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
69 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
70 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
71 | 71 | $posts = $this->postService->fetchAllArticles($page, $limit); |
72 | 72 | |
73 | 73 | return new HtmlResponse($this->template->render( |
74 | 74 | 'article::post/index', |
75 | - ['list' => $posts, 'layout' => 'layout/admin']) |
|
75 | + [ 'list' => $posts, 'layout' => 'layout/admin' ]) |
|
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return \Psr\Http\Message\ResponseInterface |
83 | 83 | */ |
84 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
84 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
85 | 85 | { |
86 | 86 | $id = $this->request->getAttribute('id'); |
87 | 87 | $post = $this->postService->fetchSingleArticle($id); |
88 | 88 | $categories = $this->categoryService->getAll(); |
89 | 89 | |
90 | 90 | if ($this->request->getParsedBody()) { |
91 | - $post = (object)($this->request->getParsedBody() + (array)$post); |
|
91 | + $post = (object) ($this->request->getParsedBody() + (array) $post); |
|
92 | 92 | $post->article_id = $id; |
93 | 93 | } |
94 | 94 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | return $this->response->withStatus(302)->withHeader( |
151 | - 'Location', $this->router->generateUri('admin.posts', ['action' => 'index']) |
|
151 | + 'Location', $this->router->generateUri('admin.posts', [ 'action' => 'index' ]) |
|
152 | 152 | ); |
153 | 153 | } |
154 | 154 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | |
69 | 69 | $article = $articleFilter->getValues(); |
70 | 70 | $article += [ |
71 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
71 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
72 | 72 | 'type' => ArticleType::DISCUSSION, |
73 | 73 | 'article_id' => $id, |
74 | 74 | 'article_uuid' => $uuId |
75 | 75 | ]; |
76 | 76 | |
77 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
78 | - unset($article['category_id'], $article['admin_user_id']); |
|
77 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
78 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
79 | 79 | |
80 | - $discussion = $discussionFilter->getValues() + ['article_uuid' => $uuId]; |
|
80 | + $discussion = $discussionFilter->getValues() + [ 'article_uuid' => $uuId ]; |
|
81 | 81 | |
82 | 82 | $this->articleMapper->insert($article); |
83 | 83 | $this->articleDiscussionsMapper->insert($discussion); |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
94 | 94 | } |
95 | 95 | |
96 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
96 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
97 | 97 | $discussion = $discussionFilter->getValues(); |
98 | 98 | |
99 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
100 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
101 | - unset($article['category_id'], $article['admin_user_id']); |
|
99 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
100 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
101 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
102 | 102 | |
103 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
104 | - $this->articleDiscussionsMapper->update($discussion, ['article_uuid' => $article['article_uuid']]); |
|
103 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
104 | + $this->articleDiscussionsMapper->update($discussion, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function deleteArticle($id) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | throw new \Exception('Article not found!'); |
113 | 113 | } |
114 | 114 | |
115 | - $this->articleDiscussionsMapper->delete(['article_uuid' => $discussion->article_uuid]); |
|
115 | + $this->articleDiscussionsMapper->delete([ 'article_uuid' => $discussion->article_uuid ]); |
|
116 | 116 | $this->delete($discussion->article_uuid); |
117 | 117 | } |
118 | 118 | } |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | public function getCategoryIds($articleId) |
33 | 33 | { |
34 | - $categories = []; |
|
34 | + $categories = [ ]; |
|
35 | 35 | foreach ($this->articleMapper->getCategories($articleId) as $category) { |
36 | - $categories[] = $category->category_id; |
|
36 | + $categories[ ] = $category->category_id; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $categories; |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | |
42 | 42 | public function delete($articleId) |
43 | 43 | { |
44 | - $this->articleMapper->delete(['article_uuid' => $articleId]); |
|
44 | + $this->articleMapper->delete([ 'article_uuid' => $articleId ]); |
|
45 | 45 | } |
46 | 46 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | [ |
20 | 20 | 'name' => 'title', |
21 | 21 | 'required' => true, |
22 | - 'filters' => [['name' => 'StringTrim']], |
|
22 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
23 | 23 | 'validators' => [ |
24 | - ['name' => 'NotEmpty'], |
|
25 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
24 | + [ 'name' => 'NotEmpty' ], |
|
25 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
26 | 26 | ], |
27 | 27 | ] |
28 | 28 | ); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | [ |
32 | 32 | 'name' => 'body', |
33 | 33 | 'required' => true, |
34 | - 'filters' => [['name' => 'StringTrim']], |
|
34 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
35 | 35 | 'validators' => [ |
36 | - ['name' => 'NotEmpty'], |
|
37 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100000]], |
|
36 | + [ 'name' => 'NotEmpty' ], |
|
37 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100000 ] ], |
|
38 | 38 | ], |
39 | 39 | ] |
40 | 40 | ); |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | [ |
44 | 44 | 'name' => 'lead', |
45 | 45 | 'required' => true, |
46 | - 'filters' => [['name' => 'StringTrim']], |
|
46 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
47 | 47 | 'validators' => [ |
48 | - ['name' => 'NotEmpty'], |
|
49 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 50000]], |
|
48 | + [ 'name' => 'NotEmpty' ], |
|
49 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 50000 ] ], |
|
50 | 50 | ], |
51 | 51 | ] |
52 | 52 | ); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | [ |
56 | 56 | 'name' => 'has_layout', |
57 | 57 | 'required' => false, |
58 | - 'filters' => [['name' => 'Boolean']], |
|
58 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
59 | 59 | ] |
60 | 60 | ); |
61 | 61 |