@@ -7,9 +7,9 @@ |
||
| 7 | 7 | |
| 8 | 8 | public function change() |
| 9 | 9 | { |
| 10 | - $this->table('newsletter', ['id' => false]) |
|
| 10 | + $this->table('newsletter', [ 'id' => false ]) |
|
| 11 | 11 | ->addColumn('email', 'text') |
| 12 | - ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP']) |
|
| 12 | + ->addColumn('created_at', 'timestamp', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
| 13 | 13 | ->create(); |
| 14 | 14 | } |
| 15 | 15 | } |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | $allUsers = array_column($articleEvents->getAdapter()->fetchAll('select admin_user_uuid from admin_users'), 'admin_user_uuid'); |
| 19 | 19 | $allCategory = array_column($articleEvents->getAdapter()->fetchAll('select category_uuid from category'), 'category_uuid'); |
| 20 | 20 | |
| 21 | - for($i = 0; $i < $count; $i++) { |
|
| 21 | + for ($i = 0; $i < $count; $i++) { |
|
| 22 | 22 | // Insert Article |
| 23 | 23 | $id = $faker->uuid; |
| 24 | 24 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
| 25 | 25 | $title = $faker->sentence(); |
| 26 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
| 27 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
| 26 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
| 27 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
| 28 | 28 | $data = [ |
| 29 | 29 | 'article_uuid' => $mysqlUuid, |
| 30 | 30 | 'article_id' => $id, |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | 'start_at' => $faker->dateTimeBetween('now', '+5 days')->format('Y-m-d H:i:s'), |
| 53 | 53 | 'end_at' => $faker->dateTimeBetween('+5 days', '+6 days')->format('Y-m-d H:i:s'), |
| 54 | 54 | 'event_url' => 'https://www.meetup.com/Tokyo-Hello-Kitty-Meetup/', |
| 55 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
| 56 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))] |
|
| 55 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
| 56 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ] |
|
| 57 | 57 | ]; |
| 58 | 58 | |
| 59 | 59 | $articleEvents->insert($data)->save(); |
@@ -11,19 +11,19 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public function getImages($faker, $type = 'people', $width = 400, $height = 400) |
| 13 | 13 | { |
| 14 | - $images = []; |
|
| 14 | + $images = [ ]; |
|
| 15 | 15 | $conf = include __DIR__ . "/../../../config/autoload/local.php"; |
| 16 | - $p = $conf['upload']['public_path']; |
|
| 16 | + $p = $conf[ 'upload' ][ 'public_path' ]; |
|
| 17 | 17 | $upload = new Upload($p, ''); |
| 18 | 18 | |
| 19 | - for($i = 0; $i < 5; $i++) { |
|
| 19 | + for ($i = 0; $i < 5; $i++) { |
|
| 20 | 20 | $filename = md5(rand()) . '.jpg'; |
| 21 | - $path = $p . $filename[0] . '/' . $filename[1] . '/' . $filename[2] . '/' . $filename; |
|
| 21 | + $path = $p . $filename[ 0 ] . '/' . $filename[ 1 ] . '/' . $filename[ 2 ] . '/' . $filename; |
|
| 22 | 22 | $upload->getPath($filename); // create sub folders |
| 23 | 23 | $img = file_get_contents($faker->imageUrl(400, 400, $type)); |
| 24 | 24 | file_put_contents($path, $img); |
| 25 | 25 | |
| 26 | - $images[] = $upload->getWebPath($filename); |
|
| 26 | + $images[ ] = $upload->getWebPath($filename); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return $images; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $faceImages = $this->getImages($faker, 'people'); |
| 38 | 38 | $profileImages = $this->getImages($faker, 'fashion'); |
| 39 | 39 | |
| 40 | - for($i = 0; $i < $count; $i++) { |
|
| 40 | + for ($i = 0; $i < $count; $i++) { |
|
| 41 | 41 | $id = $faker->uuid; |
| 42 | 42 | $mysqluuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
| 43 | 43 | |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | 'status' => rand(0, 1), |
| 52 | 52 | 'last_login' => rand(0, 10) === 7 ? null : $faker->dateTimeBetween('-10 days', 'now')->format('Y-m-d H:i:s'), |
| 53 | 53 | 'created_at' => $faker->dateTimeBetween('-20 days', '-10 days')->format('Y-m-d H:i:s'), |
| 54 | - 'face_img' => $faceImages[rand(0, (count($faceImages) - 1))], |
|
| 55 | - 'profile_img' => $profileImages[rand(0, (count($profileImages) - 1))] |
|
| 54 | + 'face_img' => $faceImages[ rand(0, (count($faceImages) - 1)) ], |
|
| 55 | + 'profile_img' => $profileImages[ rand(0, (count($profileImages) - 1)) ] |
|
| 56 | 56 | ]; |
| 57 | 57 | |
| 58 | 58 | $users->insert($data)->save(); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | $category = $this->table('category'); |
| 12 | 12 | $count = rand(5, 10); |
| 13 | 13 | |
| 14 | - for($i = 0; $i < $count; $i++) { |
|
| 14 | + for ($i = 0; $i < $count; $i++) { |
|
| 15 | 15 | $id = $faker->uuid; |
| 16 | 16 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
| 17 | 17 | $categoryName = $faker->name; |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | $allUsers = array_column($articleVideos->getAdapter()->fetchAll('select admin_user_uuid from admin_users'), 'admin_user_uuid'); |
| 27 | 27 | $allCategory = array_column($articleVideos->getAdapter()->fetchAll('select category_uuid from category'), 'category_uuid'); |
| 28 | 28 | |
| 29 | - for($i = 0; $i < $count; $i++) { |
|
| 29 | + for ($i = 0; $i < $count; $i++) { |
|
| 30 | 30 | // Insert Article |
| 31 | 31 | $id = $faker->uuid; |
| 32 | 32 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
| 33 | 33 | $title = $faker->sentence(); |
| 34 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
| 35 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
| 34 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
| 35 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
| 36 | 36 | $data = [ |
| 37 | 37 | 'article_uuid' => $mysqlUuid, |
| 38 | 38 | 'article_id' => $id, |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | 'sub_title' => $faker->sentence(), |
| 57 | 57 | 'body' => $faker->paragraph(30), |
| 58 | 58 | 'lead' => $faker->paragraph(5), |
| 59 | - 'video_url' => self::VIDEOS[rand(0, (count(self::VIDEOS) - 1))], |
|
| 60 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
| 61 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))] |
|
| 59 | + 'video_url' => self::VIDEOS[ rand(0, (count(self::VIDEOS) - 1)) ], |
|
| 60 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
| 61 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ] |
|
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | 64 | $articleVideos->insert($data)->save(); |
@@ -8,21 +8,21 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - $this->table('admin_users', ['id' => false, 'primary_key' => 'admin_user_uuid']) |
|
| 12 | - ->addColumn('admin_user_uuid', 'binary', ['limit' => 16]) |
|
| 11 | + $this->table('admin_users', [ 'id' => false, 'primary_key' => 'admin_user_uuid' ]) |
|
| 12 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
| 13 | 13 | ->addColumn('admin_user_id', 'text') |
| 14 | 14 | ->addColumn('first_name', 'text') |
| 15 | 15 | ->addColumn('last_name', 'text') |
| 16 | - ->addColumn('introduction', 'text', ['null' => true]) |
|
| 17 | - ->addColumn('biography', 'text', ['null' => true]) |
|
| 18 | - ->addColumn('email', 'string', ['limit' => 128]) |
|
| 19 | - ->addColumn('password', 'char', ['limit' => 60]) |
|
| 20 | - ->addColumn('status', 'integer', ['default' => 0])// 0 => not active, 1 = active |
|
| 21 | - ->addColumn('face_img', 'text', ['null' => true]) |
|
| 22 | - ->addColumn('profile_img', 'text', ['null' => true]) |
|
| 23 | - ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
| 24 | - ->addColumn('last_login', 'datetime', ['null' => true]) |
|
| 25 | - ->addIndex(['email'], ['name' => 'email_INDEX']) |
|
| 16 | + ->addColumn('introduction', 'text', [ 'null' => true ]) |
|
| 17 | + ->addColumn('biography', 'text', [ 'null' => true ]) |
|
| 18 | + ->addColumn('email', 'string', [ 'limit' => 128 ]) |
|
| 19 | + ->addColumn('password', 'char', [ 'limit' => 60 ]) |
|
| 20 | + ->addColumn('status', 'integer', [ 'default' => 0 ])// 0 => not active, 1 = active |
|
| 21 | + ->addColumn('face_img', 'text', [ 'null' => true ]) |
|
| 22 | + ->addColumn('profile_img', 'text', [ 'null' => true ]) |
|
| 23 | + ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
| 24 | + ->addColumn('last_login', 'datetime', [ 'null' => true ]) |
|
| 25 | + ->addIndex([ 'email' ], [ 'name' => 'email_INDEX' ]) |
|
| 26 | 26 | ->create(); |
| 27 | 27 | |
| 28 | 28 | // Insert one default admin user with password testtest |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | private function getImage($faker, $type = 'people', $width = 400, $height = 400) |
| 52 | 52 | { |
| 53 | 53 | $conf = include __DIR__ . "/../../../config/autoload/local.php"; |
| 54 | - $p = $conf['upload']['public_path']; |
|
| 54 | + $p = $conf[ 'upload' ][ 'public_path' ]; |
|
| 55 | 55 | $upload = new \UploadHelper\Upload($p, ''); |
| 56 | 56 | $filename = md5(rand()) . '.jpg'; |
| 57 | - $path = $p . $filename[0] . '/' . $filename[1] . '/' . $filename[2] . '/' . $filename; |
|
| 57 | + $path = $p . $filename[ 0 ] . '/' . $filename[ 1 ] . '/' . $filename[ 2 ] . '/' . $filename; |
|
| 58 | 58 | $upload->getPath($filename); // create sub folders |
| 59 | 59 | $img = file_get_contents($faker->imageUrl(400, 400, $type)); |
| 60 | 60 | file_put_contents($path, $img); |
@@ -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 | } |
@@ -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); |
@@ -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,50 +122,50 @@ 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' => $oldArticle->article_uuid]; |
|
| 129 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->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 don't 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 | else { |
| 144 | 144 | $this->upload->deleteFile($oldArticle->featured_img); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if (!$event['main_img']) { |
|
| 148 | - unset($event['main_img']); |
|
| 147 | + if (!$event[ 'main_img' ]) { |
|
| 148 | + unset($event[ 'main_img' ]); |
|
| 149 | 149 | } |
| 150 | 150 | else { |
| 151 | 151 | $this->upload->deleteFile($oldArticle->main_img); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 155 | - $this->articleEventsMapper->update($event, ['article_uuid' => $article['article_uuid']]); |
|
| 154 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 155 | + $this->articleEventsMapper->update($event, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | public function deleteArticle($id) |
| 159 | 159 | { |
| 160 | 160 | $event = $this->articleEventsMapper->get($id); |
| 161 | 161 | |
| 162 | - if(!$event) { |
|
| 162 | + if (!$event) { |
|
| 163 | 163 | throw new \Exception('Article not found!'); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $this->upload->deleteFile($event->main_img); |
| 167 | 167 | $this->upload->deleteFile($event->featured_img); |
| 168 | - $this->articleEventsMapper->delete(['article_uuid' => $event->article_uuid]); |
|
| 168 | + $this->articleEventsMapper->delete([ 'article_uuid' => $event->article_uuid ]); |
|
| 169 | 169 | $this->delete($event->article_uuid); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -139,15 +139,13 @@ |
||
| 139 | 139 | // We don't want to force user to re-upload image on edit |
| 140 | 140 | if (!$event['featured_img']) { |
| 141 | 141 | unset($event['featured_img']); |
| 142 | - } |
|
| 143 | - else { |
|
| 142 | + } else { |
|
| 144 | 143 | $this->upload->deleteFile($oldArticle->featured_img); |
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | if (!$event['main_img']) { |
| 148 | 147 | unset($event['main_img']); |
| 149 | - } |
|
| 150 | - else { |
|
| 148 | + } else { |
|
| 151 | 149 | $this->upload->deleteFile($oldArticle->main_img); |
| 152 | 150 | } |
| 153 | 151 | |
@@ -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 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 96 | 96 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
| 97 | 97 | |
| 98 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
| 98 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
| 99 | 99 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,19 +104,19 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | $article = $articleFilter->getValues(); |
| 106 | 106 | $article += [ |
| 107 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
| 107 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
| 108 | 108 | 'type' => ArticleType::POST, |
| 109 | 109 | 'article_id' => $id, |
| 110 | 110 | 'article_uuid' => $uuId |
| 111 | 111 | ]; |
| 112 | 112 | |
| 113 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 114 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 113 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 114 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 115 | 115 | |
| 116 | 116 | $post = $postFilter->getValues() + [ |
| 117 | 117 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 118 | 118 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
| 119 | - 'article_uuid' => $article['article_uuid'] |
|
| 119 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
| 120 | 120 | ]; |
| 121 | 121 | |
| 122 | 122 | $this->articleMapper->insert($article); |
@@ -129,37 +129,37 @@ discard block |
||
| 129 | 129 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 130 | 130 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
| 131 | 131 | |
| 132 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
| 132 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
| 133 | 133 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $article = $articleFilter->getValues() + ['article_uuid' => $oldArticle->article_uuid]; |
|
| 136 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->article_uuid ]; |
|
| 137 | 137 | $post = $postFilter->getValues() + [ |
| 138 | 138 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 139 | 139 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
| 140 | 140 | ]; |
| 141 | 141 | |
| 142 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
| 143 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 144 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 142 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
| 143 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 144 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 145 | 145 | |
| 146 | 146 | // We don't want to force user to re-upload image on edit |
| 147 | - if (!$post['featured_img']) { |
|
| 148 | - unset($post['featured_img']); |
|
| 147 | + if (!$post[ 'featured_img' ]) { |
|
| 148 | + unset($post[ 'featured_img' ]); |
|
| 149 | 149 | } |
| 150 | 150 | else { |
| 151 | 151 | $this->upload->deleteFile($oldArticle->featured_img); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if (!$post['main_img']) { |
|
| 155 | - unset($post['main_img']); |
|
| 154 | + if (!$post[ 'main_img' ]) { |
|
| 155 | + unset($post[ 'main_img' ]); |
|
| 156 | 156 | } |
| 157 | 157 | else { |
| 158 | 158 | $this->upload->deleteFile($oldArticle->main_img); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 162 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
| 161 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 162 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function deleteArticle($id) |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $this->upload->deleteFile($post->main_img); |
| 174 | 174 | $this->upload->deleteFile($post->featured_img); |
| 175 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
| 175 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
| 176 | 176 | $this->delete($post->article_uuid); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -146,15 +146,13 @@ |
||
| 146 | 146 | // We don't want to force user to re-upload image on edit |
| 147 | 147 | if (!$post['featured_img']) { |
| 148 | 148 | unset($post['featured_img']); |
| 149 | - } |
|
| 150 | - else { |
|
| 149 | + } else { |
|
| 151 | 150 | $this->upload->deleteFile($oldArticle->featured_img); |
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | if (!$post['main_img']) { |
| 155 | 154 | unset($post['main_img']); |
| 156 | - } |
|
| 157 | - else { |
|
| 155 | + } else { |
|
| 158 | 156 | $this->upload->deleteFile($oldArticle->main_img); |
| 159 | 157 | } |
| 160 | 158 | |
@@ -23,49 +23,49 @@ |
||
| 23 | 23 | /** |
| 24 | 24 | * |
| 25 | 25 | * |
| 26 | - * @var ArticleMapper |
|
| 26 | + * @var ArticleMapper |
|
| 27 | 27 | */ |
| 28 | 28 | private $articleMapper; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * |
| 32 | 32 | * |
| 33 | - * @var ArticlePostsMapper |
|
| 33 | + * @var ArticlePostsMapper |
|
| 34 | 34 | */ |
| 35 | 35 | private $articlePostsMapper; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * |
| 39 | 39 | * |
| 40 | - * @var ArticleFilter |
|
| 40 | + * @var ArticleFilter |
|
| 41 | 41 | */ |
| 42 | 42 | private $articleFilter; |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * |
| 46 | 46 | * |
| 47 | - * @var PostFilter |
|
| 47 | + * @var PostFilter |
|
| 48 | 48 | */ |
| 49 | 49 | private $postFilter; |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * |
| 53 | 53 | * |
| 54 | - * @var CategoryMapper |
|
| 54 | + * @var CategoryMapper |
|
| 55 | 55 | */ |
| 56 | 56 | private $categoryMapper; |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * |
| 60 | 60 | * |
| 61 | - * @var Upload |
|
| 61 | + * @var Upload |
|
| 62 | 62 | */ |
| 63 | 63 | private $upload; |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * |
| 67 | 67 | * |
| 68 | - * @var AdminUsersMapper |
|
| 68 | + * @var AdminUsersMapper |
|
| 69 | 69 | */ |
| 70 | 70 | private $adminUsersMapper; |
| 71 | 71 | |