@@ -63,6 +63,9 @@ |
||
63 | 63 | return $this->getPagination($select, $page, $limit); |
64 | 64 | } |
65 | 65 | |
66 | + /** |
|
67 | + * @param integer $limit |
|
68 | + */ |
|
66 | 69 | public function fetchLatest($limit) |
67 | 70 | { |
68 | 71 | return $this->articleEventsMapper->getLatest($limit); |
@@ -203,6 +203,9 @@ |
||
203 | 203 | return $this->articleMapper->getCategories($articleId); |
204 | 204 | } |
205 | 205 | |
206 | + /** |
|
207 | + * @param integer $limit |
|
208 | + */ |
|
206 | 209 | public function getLatestWeb($limit) |
207 | 210 | { |
208 | 211 | return $this->articlePostsMapper->getLatest($limit); |
@@ -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\Service; |
6 | 6 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | { |
72 | 72 | $article = $this->articlePostsMapper->getBySlug($slug); |
73 | 73 | |
74 | - if($article) { |
|
75 | - $article['categories'] = $this->getCategoryIds($article->article_id); |
|
74 | + if ($article) { |
|
75 | + $article[ 'categories' ] = $this->getCategoryIds($article->article_id); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $article; |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | { |
83 | 83 | $article = $this->articlePostsMapper->get($articleId); |
84 | 84 | |
85 | - if($article) { |
|
86 | - $article['categories'] = $this->getCategoryIds($articleId); |
|
85 | + if ($article) { |
|
86 | + $article[ 'categories' ] = $this->getCategoryIds($articleId); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $article; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
103 | 103 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
104 | 104 | |
105 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
105 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
106 | 106 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
107 | 107 | } |
108 | 108 | |
@@ -119,19 +119,19 @@ discard block |
||
119 | 119 | $post = $postFilter->getValues() + [ |
120 | 120 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
121 | 121 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
122 | - 'article_uuid' => $article['article_uuid'] |
|
122 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
123 | 123 | ]; |
124 | 124 | |
125 | - if($post['is_homepage']) { |
|
126 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
125 | + if ($post[ 'is_homepage' ]) { |
|
126 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $this->articleMapper->insert($article); |
130 | 130 | $this->articlePostsMapper->insert($post); |
131 | 131 | |
132 | - if(isset($data['categories']) && $data['categories']) { |
|
133 | - $categories = $this->categoryMapper->select(['category_id' => $data['categories']]); |
|
134 | - $this->articleMapper->insertCategories($categories, $article['article_uuid']); |
|
132 | + if (isset($data[ 'categories' ]) && $data[ 'categories' ]) { |
|
133 | + $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]); |
|
134 | + $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -141,36 +141,36 @@ discard block |
||
141 | 141 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
142 | 142 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
143 | 143 | |
144 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
144 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
145 | 145 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
146 | 146 | } |
147 | 147 | |
148 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
148 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
149 | 149 | $post = $postFilter->getValues() + [ |
150 | 150 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
151 | 151 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
152 | 152 | ]; |
153 | 153 | |
154 | 154 | // We dont want to force user to re-upload image on edit |
155 | - if(!$post['featured_img']) { |
|
156 | - unset($post['featured_img']); |
|
155 | + if (!$post[ 'featured_img' ]) { |
|
156 | + unset($post[ 'featured_img' ]); |
|
157 | 157 | } |
158 | 158 | |
159 | - if(!$post['main_img']) { |
|
160 | - unset($post['main_img']); |
|
159 | + if (!$post[ 'main_img' ]) { |
|
160 | + unset($post[ 'main_img' ]); |
|
161 | 161 | } |
162 | 162 | |
163 | - if($post['is_homepage']) { |
|
164 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
163 | + if ($post[ 'is_homepage' ]) { |
|
164 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
165 | 165 | } |
166 | 166 | |
167 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
168 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
169 | - $this->articleMapper->deleteCategories($article['article_uuid']); |
|
167 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
168 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
169 | + $this->articleMapper->deleteCategories($article[ 'article_uuid' ]); |
|
170 | 170 | |
171 | - if(isset($data['categories']) && $data['categories']) { |
|
172 | - $categories = $this->categoryMapper->select(['category_id' => $data['categories']]); |
|
173 | - $this->articleMapper->insertCategories($categories, $article['article_uuid']); |
|
171 | + if (isset($data[ 'categories' ]) && $data[ 'categories' ]) { |
|
172 | + $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]); |
|
173 | + $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | { |
179 | 179 | $post = $this->articlePostsMapper->get($id); |
180 | 180 | |
181 | - if(!$post) { |
|
181 | + if (!$post) { |
|
182 | 182 | throw new \Exception('Article not found!'); |
183 | 183 | } |
184 | 184 | |
185 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
185 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
186 | 186 | $this->delete($post->article_uuid); |
187 | 187 | } |
188 | 188 |
@@ -91,6 +91,9 @@ |
||
91 | 91 | return $this->getPagination($select, $page, $limit); |
92 | 92 | } |
93 | 93 | |
94 | + /** |
|
95 | + * @param integer $limit |
|
96 | + */ |
|
94 | 97 | public function fetchLatest($limit) |
95 | 98 | { |
96 | 99 | return $this->articleVideosMapper->getLatest($limit); |
@@ -32,6 +32,9 @@ discard block |
||
32 | 32 | $this->adapter = $adapter; |
33 | 33 | } |
34 | 34 | |
35 | + /** |
|
36 | + * @param string $id |
|
37 | + */ |
|
35 | 38 | public function get($id) |
36 | 39 | { |
37 | 40 | return $this->select(['category_id' => $id])->current(); |
@@ -44,6 +47,11 @@ discard block |
||
44 | 47 | return $select; |
45 | 48 | } |
46 | 49 | |
50 | + /** |
|
51 | + * @param integer $limit |
|
52 | + * |
|
53 | + * @return \Zend\Db\Sql\Select |
|
54 | + */ |
|
47 | 55 | public function getCategoryPostsSelect($categoryId = null, $limit = null) |
48 | 56 | { |
49 | 57 | $select = $this->getSql()->select() |
@@ -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 Category\Mapper; |
6 | 6 | |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | public function get($id) |
36 | 36 | { |
37 | - return $this->select(['category_id' => $id])->current(); |
|
37 | + return $this->select([ 'category_id' => $id ])->current(); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getPaginationSelect() |
41 | 41 | { |
42 | - $select = $this->getSql()->select()->order(['name' => 'asc']); |
|
42 | + $select = $this->getSql()->select()->order([ 'name' => 'asc' ]); |
|
43 | 43 | |
44 | 44 | return $select; |
45 | 45 | } |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | public function getCategoryPostsSelect($categoryId = null, $limit = null) |
48 | 48 | { |
49 | 49 | $select = $this->getSql()->select() |
50 | - ->columns(['category_name' => 'name', 'category_slug' => 'slug']) |
|
51 | - ->join('article_categories', 'article_categories.category_uuid = category.category_uuid', []) |
|
52 | - ->join('articles', 'articles.article_uuid = article_categories.article_uuid', ['article_id', 'slug', 'admin_user_uuid', 'published_at']) |
|
53 | - ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', ['*'], 'right') |
|
54 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name', 'face_img']) |
|
55 | - ->where(['articles.status' => 1]) |
|
56 | - ->order(['published_at' => 'desc']); |
|
57 | - |
|
58 | - if($categoryId) { |
|
59 | - $select->where(['category_id' => $categoryId]); |
|
50 | + ->columns([ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
51 | + ->join('article_categories', 'article_categories.category_uuid = category.category_uuid', [ ]) |
|
52 | + ->join('articles', 'articles.article_uuid = article_categories.article_uuid', [ 'article_id', 'slug', 'admin_user_uuid', 'published_at' ]) |
|
53 | + ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', [ '*' ], 'right') |
|
54 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name', 'face_img' ]) |
|
55 | + ->where([ 'articles.status' => 1 ]) |
|
56 | + ->order([ 'published_at' => 'desc' ]); |
|
57 | + |
|
58 | + if ($categoryId) { |
|
59 | + $select->where([ 'category_id' => $categoryId ]); |
|
60 | 60 | } |
61 | 61 | |
62 | - if($limit) { |
|
62 | + if ($limit) { |
|
63 | 63 | $select->limit($limit); |
64 | 64 | } |
65 | 65 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | $select->where->notEqualTo('slug', 'php-videos'); |
76 | 76 | $select->where->notEqualTo('slug', 'events'); |
77 | 77 | |
78 | - if($limit) { |
|
78 | + if ($limit) { |
|
79 | 79 | $select->limit($limit); |
80 | 80 | } |
81 | 81 | |
82 | - if($order) { |
|
82 | + if ($order) { |
|
83 | 83 | $select->order($order); |
84 | 84 | } else { |
85 | 85 | $select->order(new Expression('rand()')); |
@@ -13,8 +13,8 @@ |
||
13 | 13 | 'article/pagination' => 'templates/partial/pagination.phtml', |
14 | 14 | ], |
15 | 15 | 'paths' => [ |
16 | - 'templates' => ['templates'], |
|
17 | - 'web' => ['templates/web'], |
|
16 | + 'templates' => [ 'templates' ], |
|
17 | + 'web' => [ 'templates/web' ], |
|
18 | 18 | ], |
19 | 19 | ], |
20 | 20 |
@@ -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 Web\Action; |
6 | 6 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function __invoke(Request $request, Response $response, callable $next = null) |
54 | 54 | { |
55 | 55 | $params = $request->getQueryParams(); |
56 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
56 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
57 | 57 | $futureEvents = $this->eventService->fetchFutureEvents(); |
58 | 58 | $pastEvents = $this->eventService->fetchPastEventsPagination($page, 3); |
59 | 59 |
@@ -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 Web\Action; |
6 | 6 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $urlSlug1 = $request->getAttribute('segment_1'); |
49 | 49 | $urlSlug2 = $request->getAttribute('segment_2'); |
50 | 50 | |
51 | - if($urlSlug2) { |
|
51 | + if ($urlSlug2) { |
|
52 | 52 | $categorySlug = $urlSlug1; |
53 | 53 | $postSlug = $urlSlug2; |
54 | 54 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | list($previousPost, $nextPost) = $this->postService->fetchNearestArticle($post->published_at); |
63 | 63 | |
64 | - if(!$post) { |
|
64 | + if (!$post) { |
|
65 | 65 | $response = $response->withStatus(404); |
66 | 66 | |
67 | 67 | return $next($request, $response, new \Exception("Post by URL does not exist!", 404)); |
@@ -51,8 +51,7 @@ |
||
51 | 51 | if($urlSlug2) { |
52 | 52 | $categorySlug = $urlSlug1; |
53 | 53 | $postSlug = $urlSlug2; |
54 | - } |
|
55 | - else { |
|
54 | + } else { |
|
56 | 55 | $categorySlug = null; |
57 | 56 | $postSlug = $urlSlug1; |
58 | 57 | } |
@@ -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 Web\Action; |
6 | 6 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function __invoke(Request $request, Response $response, callable $next = null) |
52 | 52 | { |
53 | 53 | $params = $request->getQueryParams(); |
54 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
54 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
55 | 55 | $videos = $this->videoService->fetchWebArticles($page, 5); |
56 | 56 | |
57 | 57 | return new HtmlResponse($this->template->render('web::videos', [ |
@@ -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 | |
@@ -34,18 +34,18 @@ discard block |
||
34 | 34 | public function getPaginationSelect() |
35 | 35 | { |
36 | 36 | return $this->getSql()->select() |
37 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'is_homepage']) |
|
37 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'is_homepage' ]) |
|
38 | 38 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
39 | - ->where(['articles.type' => ArticleType::POST]) |
|
40 | - ->order(['created_at' => 'desc']); |
|
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', 'is_homepage']) |
|
46 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout', 'is_homepage' ]) |
|
47 | 47 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
48 | - ->where(['articles.article_id' => $id]); |
|
48 | + ->where([ 'articles.article_id' => $id ]); |
|
49 | 49 | |
50 | 50 | return $this->selectWith($select)->current(); |
51 | 51 | } |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | { |
55 | 55 | $select = $this->getSql()->select() |
56 | 56 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
57 | - ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', []) |
|
58 | - ->join('category', 'category.category_uuid = article_categories.category_uuid', ['category_slug' => 'slug']) |
|
57 | + ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', [ ]) |
|
58 | + ->join('category', 'category.category_uuid = article_categories.category_uuid', [ 'category_slug' => 'slug' ]) |
|
59 | 59 | ->limit(1); |
60 | 60 | |
61 | - if($direction > 0) { |
|
61 | + if ($direction > 0) { |
|
62 | 62 | $select->where->greaterThan('published_at', $publishedAt); |
63 | - $select->order(['published_at' => 'asc']); |
|
64 | - } elseif($direction < 0) { |
|
63 | + $select->order([ 'published_at' => 'asc' ]); |
|
64 | + } elseif ($direction < 0) { |
|
65 | 65 | $select->where->lessThan('published_at', $publishedAt); |
66 | - $select->order(['published_at' => 'desc']); |
|
66 | + $select->order([ 'published_at' => 'desc' ]); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | return $this->selectWith($select)->current(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $select = $this->getSql()->select() |
75 | 75 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
76 | - ->where(['article_posts.is_homepage' => true, 'articles.status' => 1]); |
|
76 | + ->where([ 'article_posts.is_homepage' => true, 'articles.status' => 1 ]); |
|
77 | 77 | |
78 | 78 | return $this->selectWith($select)->current(); |
79 | 79 | } |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | public function getBySlug($slug) |
82 | 82 | { |
83 | 83 | $select = $this->getSql()->select() |
84 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
84 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
85 | 85 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
86 | - ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', []) |
|
87 | - ->join('category', 'category.category_uuid = article_categories.category_uuid', ['category_name' => 'name', 'category_slug' => 'slug']) |
|
88 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
89 | - ->where(['articles.slug' => $slug, 'articles.status' => 1]); |
|
86 | + ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid', [ ]) |
|
87 | + ->join('category', 'category.category_uuid = article_categories.category_uuid', [ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
88 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
89 | + ->where([ 'articles.slug' => $slug, 'articles.status' => 1 ]); |
|
90 | 90 | |
91 | 91 | return $this->selectWith($select)->current(); |
92 | 92 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public function getAll() |
95 | 95 | { |
96 | 96 | $select = $this->getSql()->select() |
97 | - ->join('articles', 'article_posts.article_uuid = articles.article_uuid', ['article_id', 'slug']); |
|
97 | + ->join('articles', 'article_posts.article_uuid = articles.article_uuid', [ 'article_id', 'slug' ]); |
|
98 | 98 | |
99 | 99 | return $this->selectWith($select); |
100 | 100 | } |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | { |
107 | 107 | $select = $this->getSql()->select() |
108 | 108 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
109 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
109 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
110 | 110 | ->join('article_categories', 'article_categories.article_uuid = articles.article_uuid') |
111 | 111 | ->join('category', 'category.category_uuid = article_categories.category_uuid', |
112 | - ['category_name' => 'name', 'category_id', 'category_slug' => 'slug']) |
|
113 | - ->where(['articles.status' => 1]) |
|
114 | - ->order(['articles.published_at' => 'desc']) |
|
112 | + [ 'category_name' => 'name', 'category_id', 'category_slug' => 'slug' ]) |
|
113 | + ->where([ 'articles.status' => 1 ]) |
|
114 | + ->order([ 'articles.published_at' => 'desc' ]) |
|
115 | 115 | ->limit($limit); |
116 | 116 | |
117 | 117 | return $this->selectWith($select); |