@@ -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\Service; |
| 6 | 6 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 107 | 107 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
| 108 | 108 | |
| 109 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 109 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 110 | 110 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $article = $articleFilter->getValues(); |
| 117 | 117 | $article += [ |
| 118 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
| 118 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
| 119 | 119 | 'type' => ArticleType::VIDEO, |
| 120 | 120 | 'article_id' => $id, |
| 121 | 121 | 'article_uuid' => $uuId |
| 122 | 122 | ]; |
| 123 | 123 | |
| 124 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 125 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 124 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 125 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 126 | 126 | |
| 127 | 127 | $videos = $videosFilter->getValues() + [ |
| 128 | 128 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 141 | 141 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
| 142 | 142 | |
| 143 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 143 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 144 | 144 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
| 148 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 149 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
| 150 | - unset($article['category_id']); |
|
| 151 | - unset($article['admin_user_id']); |
|
| 147 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
| 148 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 149 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
| 150 | + unset($article[ 'category_id' ]); |
|
| 151 | + unset($article[ 'admin_user_id' ]); |
|
| 152 | 152 | |
| 153 | 153 | $videos = $videosFilter->getValues() + [ |
| 154 | 154 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -156,27 +156,27 @@ discard block |
||
| 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 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 88 | 88 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
| 89 | 89 | |
| 90 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 90 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 91 | 91 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $article = $articleFilter->getValues(); |
| 98 | 98 | $article += [ |
| 99 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
| 99 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
| 100 | 100 | 'type' => ArticleType::EVENT, |
| 101 | 101 | 'article_id' => $id, |
| 102 | 102 | 'article_uuid' => $uuId |
| 103 | 103 | ]; |
| 104 | - unset($article['admin_user_id']); |
|
| 104 | + unset($article[ 'admin_user_id' ]); |
|
| 105 | 105 | |
| 106 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 107 | - unset($article['category_id']); |
|
| 106 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 107 | + unset($article[ 'category_id' ]); |
|
| 108 | 108 | |
| 109 | 109 | $event = $eventFilter->getValues() + [ |
| 110 | 110 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -122,42 +122,42 @@ discard block |
||
| 122 | 122 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 123 | 123 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
| 124 | 124 | |
| 125 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 125 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 126 | 126 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
| 129 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
| 130 | 130 | $event = $eventFilter->getValues() + [ |
| 131 | 131 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 132 | 132 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
| 133 | 133 | ]; |
| 134 | 134 | |
| 135 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
| 136 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 137 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 135 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
| 136 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 137 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 138 | 138 | |
| 139 | 139 | // We dont want to force user to re-upload image on edit |
| 140 | - if(!$event['featured_img']) { |
|
| 141 | - unset($event['featured_img']); |
|
| 140 | + if (!$event[ 'featured_img' ]) { |
|
| 141 | + unset($event[ 'featured_img' ]); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if(!$event['main_img']) { |
|
| 145 | - unset($event['main_img']); |
|
| 144 | + if (!$event[ 'main_img' ]) { |
|
| 145 | + unset($event[ 'main_img' ]); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 149 | - $this->articleEventsMapper->update($event, ['article_uuid' => $article['article_uuid']]); |
|
| 148 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 149 | + $this->articleEventsMapper->update($event, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function deleteArticle($id) |
| 153 | 153 | { |
| 154 | 154 | $event = $this->articleEventsMapper->get($id); |
| 155 | 155 | |
| 156 | - if(!$event) { |
|
| 156 | + if (!$event) { |
|
| 157 | 157 | throw new \Exception('Article not found!'); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $this->articleEventsMapper->delete(['article_uuid' => $event->article_uuid]); |
|
| 160 | + $this->articleEventsMapper->delete([ 'article_uuid' => $event->article_uuid ]); |
|
| 161 | 161 | $this->delete($event->article_uuid); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -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 |
@@ -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 | $posts = $this->postService->fetchAllArticles($page, $limit); |
| 74 | 74 | |
| 75 | - return new HtmlResponse($this->template->render('article::post/index', ['list' => $posts, 'layout' => 'layout/admin'])); |
|
| 75 | + return new HtmlResponse($this->template->render('article::post/index', [ 'list' => $posts, '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 | $post = $this->postService->fetchSingleArticle($id); |
| 87 | 87 | $categories = $this->categoryService->getAll(); |
| 88 | 88 | |
| 89 | - if($this->request->getParsedBody()){ |
|
| 90 | - $post = (object)($this->request->getParsedBody() + (array)$post); |
|
| 89 | + if ($this->request->getParsedBody()) { |
|
| 90 | + $post = (object) ($this->request->getParsedBody() + (array) $post); |
|
| 91 | 91 | $post->article_id = $id; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function save() : \Psr\Http\Message\ResponseInterface |
| 110 | 110 | { |
| 111 | - try{ |
|
| 111 | + try { |
|
| 112 | 112 | $id = $this->request->getAttribute('id'); |
| 113 | 113 | $user = $this->session->getStorage()->user; |
| 114 | 114 | $data = $this->request->getParsedBody(); |
| 115 | 115 | $data += (new Request())->getFiles()->toArray(); |
| 116 | 116 | |
| 117 | - if($id){ |
|
| 117 | + if ($id) { |
|
| 118 | 118 | $this->postService->updateArticle($data, $id); |
| 119 | 119 | } |
| 120 | - else{ |
|
| 120 | + else { |
|
| 121 | 121 | $this->postService->createArticle($user, $data); |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - catch(FilterException $fe){ |
|
| 124 | + catch (FilterException $fe) { |
|
| 125 | 125 | return $this->edit($fe->getArrayMessages()); |
| 126 | 126 | } |
| 127 | - catch(\Exception $e){ |
|
| 127 | + catch (\Exception $e) { |
|
| 128 | 128 | throw $e; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -139,15 +139,15 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function delete() : \Psr\Http\Message\ResponseInterface |
| 141 | 141 | { |
| 142 | - try{ |
|
| 142 | + try { |
|
| 143 | 143 | $this->postService->deleteArticle($this->request->getAttribute('id')); |
| 144 | 144 | } |
| 145 | - catch(\Exception $e){ |
|
| 145 | + catch (\Exception $e) { |
|
| 146 | 146 | throw $e; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $this->response->withStatus(302)->withHeader( |
| 150 | - 'Location', $this->router->generateUri('admin.posts', ['action' => 'index']) |
|
| 150 | + 'Location', $this->router->generateUri('admin.posts', [ 'action' => 'index' ]) |
|
| 151 | 151 | ); |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -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 | |
@@ -52,22 +52,22 @@ discard block |
||
| 52 | 52 | public function index(): \Psr\Http\Message\ResponseInterface |
| 53 | 53 | { |
| 54 | 54 | $params = $this->request->getQueryParams(); |
| 55 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
| 56 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
| 55 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
| 56 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
| 57 | 57 | |
| 58 | 58 | $discussions = $this->discussionService->fetchAllArticles($page, $limit); |
| 59 | 59 | |
| 60 | - return new HtmlResponse($this->template->render('article::discussion/index', ['list' => $discussions, 'layout' => 'layout/admin'])); |
|
| 60 | + return new HtmlResponse($this->template->render('article::discussion/index', [ 'list' => $discussions, 'layout' => 'layout/admin' ])); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
| 63 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
| 64 | 64 | { |
| 65 | 65 | $id = $this->request->getAttribute('id'); |
| 66 | 66 | $discussion = $this->discussionService->fetchSingleArticle($id); |
| 67 | 67 | $categories = $this->categoryService->getAll(); |
| 68 | 68 | |
| 69 | - if($this->request->getParsedBody()) { |
|
| 70 | - $discussion = (object)($this->request->getParsedBody() + (array)$discussion); |
|
| 69 | + if ($this->request->getParsedBody()) { |
|
| 70 | + $discussion = (object) ($this->request->getParsedBody() + (array) $discussion); |
|
| 71 | 71 | $discussion->article_id = $id; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | $data = $this->request->getParsedBody(); |
| 87 | 87 | $user = $this->session->getStorage()->user; |
| 88 | 88 | |
| 89 | - if($id) { |
|
| 89 | + if ($id) { |
|
| 90 | 90 | $this->discussionService->updateArticle($data, $id); |
| 91 | 91 | } else { |
| 92 | 92 | $this->discussionService->createArticle($user, $data); |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | - catch(FilterException $fe) { |
|
| 95 | + catch (FilterException $fe) { |
|
| 96 | 96 | return $this->edit($fe->getArrayMessages()); |
| 97 | 97 | } |
| 98 | - catch(\Exception $e) { |
|
| 98 | + catch (\Exception $e) { |
|
| 99 | 99 | throw $e; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | try { |
| 108 | 108 | $this->discussionService->deleteArticle($this->request->getAttribute('id')); |
| 109 | 109 | } |
| 110 | - catch(\Exception $e) { |
|
| 110 | + catch (\Exception $e) { |
|
| 111 | 111 | throw $e; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -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 | } |
@@ -12,26 +12,26 @@ |
||
| 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' => 'title', |
| 20 | 20 | 'required' => true, |
| 21 | - 'filters' => [['name' => 'StringTrim']], |
|
| 21 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 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' => 'body', |
| 30 | 30 | 'required' => true, |
| 31 | - 'filters' => [['name' => 'StringTrim']], |
|
| 31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 32 | 32 | 'validators' => [ |
| 33 | - ['name' => 'NotEmpty'], |
|
| 34 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 1500]], |
|
| 33 | + [ 'name' => 'NotEmpty' ], |
|
| 34 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 1500 ] ], |
|
| 35 | 35 | ], |
| 36 | 36 | ]); |
| 37 | 37 | |