@@ -4,7 +4,6 @@ |
||
4 | 4 | use MysqlUuid\Formats\Binary; |
5 | 5 | use MysqlUuid\Uuid; |
6 | 6 | use Core\Entity\ArticleType; |
7 | -use MysqlUuid\Formats\PlainString; |
|
8 | 7 | |
9 | 8 | class ArticleDiscussions extends AbstractMigration |
10 | 9 | { |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use Zend\Db\Adapter\AdapterAwareInterface; |
8 | 8 | use Zend\Db\TableGateway\AbstractTableGateway; |
9 | 9 | use Zend\Db\Sql\Delete; |
10 | -use Zend\Db\Sql\Insert; |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * Class ArticleMapper. |
@@ -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 | } |
@@ -44,6 +44,9 @@ |
||
44 | 44 | return $select; |
45 | 45 | } |
46 | 46 | |
47 | + /** |
|
48 | + * @param integer $limit |
|
49 | + */ |
|
47 | 50 | public function getCategoryPostsSelect($categoryId = null, $limit = null) |
48 | 51 | { |
49 | 52 | $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,18 +47,18 @@ 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('articles', 'articles.category_uuid = category.category_uuid', ['article_id', 'slug', 'admin_user_uuid', 'published_at']) |
|
52 | - ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', ['*'], 'right') |
|
53 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name', 'face_img']) |
|
54 | - ->where(['articles.status' => 1]) |
|
55 | - ->order(['published_at' => 'desc']); |
|
56 | - |
|
57 | - if($categoryId) { |
|
58 | - $select->where(['category_id' => $categoryId]); |
|
50 | + ->columns([ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
51 | + ->join('articles', 'articles.category_uuid = category.category_uuid', [ 'article_id', 'slug', 'admin_user_uuid', 'published_at' ]) |
|
52 | + ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', [ '*' ], 'right') |
|
53 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name', 'face_img' ]) |
|
54 | + ->where([ 'articles.status' => 1 ]) |
|
55 | + ->order([ 'published_at' => 'desc' ]); |
|
56 | + |
|
57 | + if ($categoryId) { |
|
58 | + $select->where([ 'category_id' => $categoryId ]); |
|
59 | 59 | } |
60 | 60 | |
61 | - if($limit) { |
|
61 | + if ($limit) { |
|
62 | 62 | $select->limit($limit); |
63 | 63 | } |
64 | 64 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | $select->where->notEqualTo('slug', 'php-videos'); |
75 | 75 | $select->where->notEqualTo('slug', 'events'); |
76 | 76 | |
77 | - if($limit) { |
|
77 | + if ($limit) { |
|
78 | 78 | $select->limit($limit); |
79 | 79 | } |
80 | 80 | |
81 | - if($order) { |
|
81 | + if ($order) { |
|
82 | 82 | $select->order($order); |
83 | 83 | } else { |
84 | 84 | $select->order(new Expression('rand()')); |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | |
13 | 13 | public function getInputFilter() |
14 | 14 | { |
15 | - if(!$this->inputFilter) { |
|
15 | + if (!$this->inputFilter) { |
|
16 | 16 | $inputFilter = new InputFilter(); |
17 | 17 | |
18 | 18 | $inputFilter->add([ |
19 | 19 | 'name' => 'slug', |
20 | 20 | 'required' => true, |
21 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
21 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
22 | 22 | 'validators' => [ |
23 | - ['name' => 'NotEmpty'], |
|
24 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
23 | + [ 'name' => 'NotEmpty' ], |
|
24 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
25 | 25 | ], |
26 | 26 | ]); |
27 | 27 | |
28 | 28 | $inputFilter->add([ |
29 | 29 | 'name' => 'published_at', |
30 | 30 | 'required' => true, |
31 | - 'filters' => [['name' => 'StringTrim']], |
|
32 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
32 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
33 | 33 | ]); |
34 | 34 | |
35 | 35 | $inputFilter->add([ |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | $inputFilter->add([ |
41 | 41 | 'name' => 'status', |
42 | 42 | 'required' => false, |
43 | - 'filters' => [['name' => 'Boolean']], |
|
43 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
44 | 44 | ]); |
45 | 45 | |
46 | 46 | $inputFilter->add([ |
47 | 47 | 'name' => 'is_wysiwyg_editor', |
48 | 48 | 'required' => false, |
49 | - 'filters' => [['name' => 'Boolean']], |
|
49 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
50 | 50 | ]); |
51 | 51 | |
52 | 52 | $this->inputFilter = $inputFilter; |
@@ -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 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
112 | 112 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
113 | 113 | |
114 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
114 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
115 | 115 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
116 | 116 | } |
117 | 117 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | 'article_uuid' => $uuId |
125 | 125 | ]; |
126 | 126 | |
127 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
128 | - unset($article['category_id']); |
|
127 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
128 | + unset($article[ 'category_id' ]); |
|
129 | 129 | |
130 | 130 | $videos = $videosFilter->getValues() + [ |
131 | 131 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -143,40 +143,40 @@ discard block |
||
143 | 143 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
144 | 144 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
145 | 145 | |
146 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
146 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
147 | 147 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
148 | 148 | } |
149 | 149 | |
150 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
151 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
152 | - unset($article['category_id']); |
|
150 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
151 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
152 | + unset($article[ 'category_id' ]); |
|
153 | 153 | $videos = $videosFilter->getValues() + [ |
154 | 154 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
155 | 155 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
156 | 156 | ]; |
157 | 157 | |
158 | 158 | // We dont want to force user to re-upload image on edit |
159 | - if(!$videos['featured_img']) { |
|
160 | - unset($videos['featured_img']); |
|
159 | + if (!$videos[ 'featured_img' ]) { |
|
160 | + unset($videos[ 'featured_img' ]); |
|
161 | 161 | } |
162 | 162 | |
163 | - if(!$videos['main_img']) { |
|
164 | - unset($videos['main_img']); |
|
163 | + if (!$videos[ 'main_img' ]) { |
|
164 | + unset($videos[ 'main_img' ]); |
|
165 | 165 | } |
166 | 166 | |
167 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
168 | - $this->articleVideosMapper->update($videos, ['article_uuid' => $article['article_uuid']]); |
|
167 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
168 | + $this->articleVideosMapper->update($videos, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | public function deleteArticle($id) |
172 | 172 | { |
173 | 173 | $video = $this->articleVideosMapper->get($id); |
174 | 174 | |
175 | - if(!$video) { |
|
175 | + if (!$video) { |
|
176 | 176 | throw new \Exception('Article not found!'); |
177 | 177 | } |
178 | 178 | |
179 | - $this->articleVideosMapper->delete(['article_uuid' => $video->article_uuid]); |
|
179 | + $this->articleVideosMapper->delete([ 'article_uuid' => $video->article_uuid ]); |
|
180 | 180 | $this->delete($video->article_uuid); |
181 | 181 | } |
182 | 182 |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | public function getCategoryIds($articleId) |
33 | 33 | { |
34 | - $categories = []; |
|
35 | - foreach($this->articleMapper->getCategories($articleId) as $category) { |
|
36 | - $categories[] = $category->category_id; |
|
34 | + $categories = [ ]; |
|
35 | + foreach ($this->articleMapper->getCategories($articleId) as $category) { |
|
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 | } |
47 | 47 | \ No newline at end of file |
@@ -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 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
91 | 91 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
92 | 92 | |
93 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
93 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
94 | 94 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
95 | 95 | } |
96 | 96 | |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | 'article_uuid' => $uuId |
105 | 105 | ]; |
106 | 106 | |
107 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
108 | - unset($article['category_id']); |
|
107 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
108 | + unset($article[ 'category_id' ]); |
|
109 | 109 | |
110 | 110 | $post = $postFilter->getValues() + [ |
111 | 111 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
112 | 112 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
113 | - 'article_uuid' => $article['article_uuid'] |
|
113 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
114 | 114 | ]; |
115 | 115 | |
116 | - if($post['is_homepage']) { |
|
117 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
116 | + if ($post[ 'is_homepage' ]) { |
|
117 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->articleMapper->insert($article); |
@@ -127,45 +127,45 @@ discard block |
||
127 | 127 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
128 | 128 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
129 | 129 | |
130 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
130 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
131 | 131 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
132 | 132 | } |
133 | 133 | |
134 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
134 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
135 | 135 | $post = $postFilter->getValues() + [ |
136 | 136 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
137 | 137 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
138 | 138 | ]; |
139 | 139 | |
140 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
141 | - unset($article['category_id']); |
|
140 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
141 | + unset($article[ 'category_id' ]); |
|
142 | 142 | |
143 | 143 | // We dont want to force user to re-upload image on edit |
144 | - if(!$post['featured_img']) { |
|
145 | - unset($post['featured_img']); |
|
144 | + if (!$post[ 'featured_img' ]) { |
|
145 | + unset($post[ 'featured_img' ]); |
|
146 | 146 | } |
147 | 147 | |
148 | - if(!$post['main_img']) { |
|
149 | - unset($post['main_img']); |
|
148 | + if (!$post[ 'main_img' ]) { |
|
149 | + unset($post[ 'main_img' ]); |
|
150 | 150 | } |
151 | 151 | |
152 | - if($post['is_homepage']) { |
|
153 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
152 | + if ($post[ 'is_homepage' ]) { |
|
153 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
154 | 154 | } |
155 | 155 | |
156 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
157 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
156 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
157 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function deleteArticle($id) |
161 | 161 | { |
162 | 162 | $post = $this->articlePostsMapper->get($id); |
163 | 163 | |
164 | - if(!$post) { |
|
164 | + if (!$post) { |
|
165 | 165 | throw new \Exception('Article not found!'); |
166 | 166 | } |
167 | 167 | |
168 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
168 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
169 | 169 | $this->delete($post->article_uuid); |
170 | 170 | } |
171 | 171 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
51 | 51 | $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data); |
52 | 52 | |
53 | - if(!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
53 | + if (!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
54 | 54 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
55 | 55 | } |
56 | 56 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | 'article_uuid' => $uuId |
65 | 65 | ]; |
66 | 66 | |
67 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
68 | - unset($article['category_id']); |
|
67 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
68 | + unset($article[ 'category_id' ]); |
|
69 | 69 | |
70 | - $discussion = $discussionFilter->getValues() + ['article_uuid' => $uuId]; |
|
70 | + $discussion = $discussionFilter->getValues() + [ 'article_uuid' => $uuId ]; |
|
71 | 71 | |
72 | 72 | $this->articleMapper->insert($article); |
73 | 73 | $this->articleDiscussionsMapper->insert($discussion); |
@@ -79,29 +79,29 @@ discard block |
||
79 | 79 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
80 | 80 | $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data); |
81 | 81 | |
82 | - if(!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
82 | + if (!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
83 | 83 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
84 | 84 | } |
85 | 85 | |
86 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
86 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
87 | 87 | $discussion = $discussionFilter->getValues(); |
88 | 88 | |
89 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
90 | - unset($article['category_id']); |
|
89 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
90 | + unset($article[ 'category_id' ]); |
|
91 | 91 | |
92 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
93 | - $this->articleDiscussionsMapper->update($discussion, ['article_uuid' => $article['article_uuid']]); |
|
92 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
93 | + $this->articleDiscussionsMapper->update($discussion, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function deleteArticle($id) |
97 | 97 | { |
98 | 98 | $discussion = $this->articleDiscussionsMapper->get($id); |
99 | 99 | |
100 | - if(!$discussion) { |
|
100 | + if (!$discussion) { |
|
101 | 101 | throw new \Exception('Article not found!'); |
102 | 102 | } |
103 | 103 | |
104 | - $this->articleDiscussionsMapper->delete(['article_uuid' => $discussion->article_uuid]); |
|
104 | + $this->articleDiscussionsMapper->delete([ 'article_uuid' => $discussion->article_uuid ]); |
|
105 | 105 | $this->delete($discussion->article_uuid); |
106 | 106 | } |
107 | 107 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
84 | 84 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
85 | 85 | |
86 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
86 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
87 | 87 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
88 | 88 | } |
89 | 89 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | 'article_uuid' => $uuId |
98 | 98 | ]; |
99 | 99 | |
100 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
101 | - unset($article['category_id']); |
|
100 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
101 | + unset($article[ 'category_id' ]); |
|
102 | 102 | |
103 | 103 | $event = $eventFilter->getValues() + [ |
104 | 104 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -116,41 +116,41 @@ discard block |
||
116 | 116 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
117 | 117 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
118 | 118 | |
119 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
119 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
120 | 120 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
121 | 121 | } |
122 | 122 | |
123 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
123 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
124 | 124 | $event = $eventFilter->getValues() + [ |
125 | 125 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
126 | 126 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
127 | 127 | ]; |
128 | 128 | |
129 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
130 | - unset($article['category_id']); |
|
129 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
130 | + unset($article[ 'category_id' ]); |
|
131 | 131 | |
132 | 132 | // We dont want to force user to re-upload image on edit |
133 | - if(!$event['featured_img']) { |
|
134 | - unset($event['featured_img']); |
|
133 | + if (!$event[ 'featured_img' ]) { |
|
134 | + unset($event[ 'featured_img' ]); |
|
135 | 135 | } |
136 | 136 | |
137 | - if(!$event['main_img']) { |
|
138 | - unset($event['main_img']); |
|
137 | + if (!$event[ 'main_img' ]) { |
|
138 | + unset($event[ 'main_img' ]); |
|
139 | 139 | } |
140 | 140 | |
141 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
142 | - $this->articleEventsMapper->update($event, ['article_uuid' => $article['article_uuid']]); |
|
141 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
142 | + $this->articleEventsMapper->update($event, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | public function deleteArticle($id) |
146 | 146 | { |
147 | 147 | $event = $this->articleEventsMapper->get($id); |
148 | 148 | |
149 | - if(!$event) { |
|
149 | + if (!$event) { |
|
150 | 150 | throw new \Exception('Article not found!'); |
151 | 151 | } |
152 | 152 | |
153 | - $this->articleEventsMapper->delete(['article_uuid' => $event->article_uuid]); |
|
153 | + $this->articleEventsMapper->delete([ 'article_uuid' => $event->article_uuid ]); |
|
154 | 154 | $this->delete($event->article_uuid); |
155 | 155 | } |
156 | 156 |