@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $event = $this->articleEventsMapper->get($articleId); |
| 49 | 49 | |
| 50 | - if($event) { |
|
| 51 | - $event['categories'] = $this->getCategoryIds($articleId); |
|
| 50 | + if ($event) { |
|
| 51 | + $event[ 'categories' ] = $this->getCategoryIds($articleId); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return $event; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 60 | 60 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
| 61 | 61 | |
| 62 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 62 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 63 | 63 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | $this->articleMapper->insert($article); |
| 83 | 83 | $this->articleEventsMapper->insert($event); |
| 84 | 84 | |
| 85 | - if(isset($data['categories']) && $data['categories']) { |
|
| 86 | - $categories = $this->categoryMapper->select(['category_id' => $data['categories']]); |
|
| 87 | - $this->articleMapper->insertCategories($categories, $article['article_uuid']); |
|
| 85 | + if (isset($data[ 'categories' ]) && $data[ 'categories' ]) { |
|
| 86 | + $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]); |
|
| 87 | + $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,32 +94,32 @@ discard block |
||
| 94 | 94 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 95 | 95 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
| 96 | 96 | |
| 97 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 97 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
| 98 | 98 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
| 101 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
| 102 | 102 | $event = $eventFilter->getValues() + [ |
| 103 | 103 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 104 | 104 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
| 105 | 105 | ]; |
| 106 | 106 | |
| 107 | 107 | // We dont want to force user to re-upload image on edit |
| 108 | - if(!$event['featured_img']) { |
|
| 109 | - unset($event['featured_img']); |
|
| 108 | + if (!$event[ 'featured_img' ]) { |
|
| 109 | + unset($event[ 'featured_img' ]); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if(!$event['main_img']) { |
|
| 113 | - unset($event['main_img']); |
|
| 112 | + if (!$event[ 'main_img' ]) { |
|
| 113 | + unset($event[ 'main_img' ]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 117 | - $this->articleEventsMapper->update($event, ['article_uuid' => $article['article_uuid']]); |
|
| 118 | - $this->articleMapper->deleteCategories($article['article_uuid']); |
|
| 116 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 117 | + $this->articleEventsMapper->update($event, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 118 | + $this->articleMapper->deleteCategories($article[ 'article_uuid' ]); |
|
| 119 | 119 | |
| 120 | - if(isset($data['categories']) && $data['categories']) { |
|
| 121 | - $categories = $this->categoryMapper->select(['category_id' => $data['categories']]); |
|
| 122 | - $this->articleMapper->insertCategories($categories, $article['article_uuid']); |
|
| 120 | + if (isset($data[ 'categories' ]) && $data[ 'categories' ]) { |
|
| 121 | + $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]); |
|
| 122 | + $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $event = $this->articleEventsMapper->get($id); |
| 129 | 129 | |
| 130 | - if(!$event) { |
|
| 130 | + if (!$event) { |
|
| 131 | 131 | throw new \Exception('Article not found!'); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $this->articleEventsMapper->delete(['article_uuid' => $event->article_uuid]); |
|
| 134 | + $this->articleEventsMapper->delete([ 'article_uuid' => $event->article_uuid ]); |
|
| 135 | 135 | $this->delete($event->article_uuid); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -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; |
@@ -42,6 +42,6 @@ discard block |
||
| 42 | 42 | public function delete($articleId) |
| 43 | 43 | { |
| 44 | 44 | $this->articleMapper->deleteCategories($articleId); |
| 45 | - $this->articleMapper->delete(['article_uuid' => $articleId]); |
|
| 45 | + $this->articleMapper->delete([ 'article_uuid' => $articleId ]); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -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\Factory\Service; |
| 5 | 5 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __invoke(ContainerInterface $container): PostService |
| 22 | 22 | { |
| 23 | - $config = $container->get('config')['upload']; |
|
| 24 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 23 | + $config = $container->get('config')[ 'upload' ]; |
|
| 24 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 25 | 25 | |
| 26 | 26 | return new PostService( |
| 27 | 27 | $container->get(ArticleMapper::class), |
@@ -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\Factory\Service; |
| 5 | 5 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __invoke(ContainerInterface $container): VideoService |
| 23 | 23 | { |
| 24 | - $config = $container->get('config')['upload']; |
|
| 25 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 24 | + $config = $container->get('config')[ 'upload' ]; |
|
| 25 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 26 | 26 | |
| 27 | 27 | return new VideoService( |
| 28 | 28 | $container->get(ArticleMapper::class), |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public function __invoke(ContainerInterface $container) |
| 21 | 21 | { |
| 22 | - $config = $container->get('config')['upload']; |
|
| 23 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 22 | + $config = $container->get('config')[ 'upload' ]; |
|
| 23 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 24 | 24 | |
| 25 | 25 | return new EventService( |
| 26 | 26 | $container->get(ArticleMapper::class), |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Article\Factory\Controller; |
| 5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | return [ |
| 12 | 12 | 'templates' => [ |
| 13 | 13 | 'paths' => [ |
| 14 | - 'article' => [__DIR__ . '/../templates/article'], |
|
| 14 | + 'article' => [ __DIR__ . '/../templates/article' ], |
|
| 15 | 15 | ], |
| 16 | 16 | ], |
| 17 | 17 | |
@@ -51,49 +51,49 @@ discard block |
||
| 51 | 51 | 'name' => 'admin.posts', |
| 52 | 52 | 'path' => '/admin/posts', |
| 53 | 53 | 'middleware' => Controller\PostController::class, |
| 54 | - 'allowed_methods' => ['GET'], |
|
| 54 | + 'allowed_methods' => [ 'GET' ], |
|
| 55 | 55 | ], |
| 56 | 56 | [ |
| 57 | 57 | 'name' => 'admin.posts.action', |
| 58 | 58 | 'path' => '/admin/posts/:action/:id', |
| 59 | 59 | 'middleware' => Controller\PostController::class, |
| 60 | - 'allowed_methods' => ['GET', 'POST'], |
|
| 60 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
| 61 | 61 | ], |
| 62 | 62 | [ |
| 63 | 63 | 'name' => 'admin.discussions', |
| 64 | 64 | 'path' => '/admin/discussions', |
| 65 | 65 | 'middleware' => Controller\DiscussionController::class, |
| 66 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 66 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 67 | 67 | ], |
| 68 | 68 | [ |
| 69 | 69 | 'name' => 'admin.discussions.action', |
| 70 | 70 | 'path' => '/admin/discussions/:action/:id', |
| 71 | 71 | 'middleware' => Controller\DiscussionController::class, |
| 72 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 72 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 73 | 73 | ], |
| 74 | 74 | [ |
| 75 | 75 | 'name' => 'admin.events', |
| 76 | 76 | 'path' => '/admin/events', |
| 77 | 77 | 'middleware' => Controller\EventController::class, |
| 78 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 78 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 79 | 79 | ], |
| 80 | 80 | [ |
| 81 | 81 | 'name' => 'admin.events.action', |
| 82 | 82 | 'path' => '/admin/events/:action/:id', |
| 83 | 83 | 'middleware' => Controller\EventController::class, |
| 84 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 84 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 85 | 85 | ], |
| 86 | 86 | [ |
| 87 | 87 | 'name' => 'admin.videos', |
| 88 | 88 | 'path' => '/admin/videos', |
| 89 | 89 | 'middleware' => Controller\VideoController::class, |
| 90 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 90 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 91 | 91 | ], |
| 92 | 92 | [ |
| 93 | 93 | 'name' => 'admin.videos.action', |
| 94 | 94 | 'path' => '/admin/videos/:action/:id', |
| 95 | 95 | 'middleware' => Controller\VideoController::class, |
| 96 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 96 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 97 | 97 | ] |
| 98 | 98 | ], |
| 99 | 99 | |
@@ -21,18 +21,18 @@ |
||
| 21 | 21 | public function getPaginationSelect() |
| 22 | 22 | { |
| 23 | 23 | return $this->getSql()->select() |
| 24 | - ->columns(['title', 'body']) |
|
| 24 | + ->columns([ 'title', 'body' ]) |
|
| 25 | 25 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
| 26 | - ->where(['articles.type' => ArticleType::DISCUSSION]) |
|
| 27 | - ->order(['created_at' => 'desc']); |
|
| 26 | + ->where([ 'articles.type' => ArticleType::DISCUSSION ]) |
|
| 27 | + ->order([ 'created_at' => 'desc' ]); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function get($id) |
| 31 | 31 | { |
| 32 | 32 | $select = $this->getSql()->select() |
| 33 | - ->columns(['title', 'body']) |
|
| 33 | + ->columns([ 'title', 'body' ]) |
|
| 34 | 34 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
| 35 | - ->where(['articles.article_id' => $id]); |
|
| 35 | + ->where([ 'articles.article_id' => $id ]); |
|
| 36 | 36 | |
| 37 | 37 | return $this->selectWith($select)->current(); |
| 38 | 38 | } |
@@ -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,10 +45,10 @@ discard block |
||
| 45 | 45 | public function getCategories($articleId) |
| 46 | 46 | { |
| 47 | 47 | $select = $this->getSql()->select() |
| 48 | - ->columns([]) |
|
| 48 | + ->columns([ ]) |
|
| 49 | 49 | ->join('article_categories', 'articles.article_uuid = article_categories.article_uuid') |
| 50 | - ->join('category', 'article_categories.category_uuid = category.category_uuid', ['name', 'slug', 'category_id']) |
|
| 51 | - ->where(['articles.article_id' => $articleId]); |
|
| 50 | + ->join('category', 'article_categories.category_uuid = category.category_uuid', [ 'name', 'slug', 'category_id' ]) |
|
| 51 | + ->where([ 'articles.article_id' => $articleId ]); |
|
| 52 | 52 | |
| 53 | 53 | return $this->selectWith($select); |
| 54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $platform = $this->getAdapter()->getPlatform(); |
| 62 | 62 | $adapter = $this->getAdapter(); |
| 63 | - $deleteQuery = (new Delete('article_categories'))->where(['article_uuid' => $id]); |
|
| 63 | + $deleteQuery = (new Delete('article_categories'))->where([ 'article_uuid' => $id ]); |
|
| 64 | 64 | |
| 65 | 65 | return $adapter->query($deleteQuery->getSqlString($platform))->execute(); |
| 66 | 66 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $platform = $this->getAdapter()->getPlatform(); |
| 74 | 74 | $adapter = $this->getAdapter(); |
| 75 | 75 | |
| 76 | - foreach($categories as $category) { |
|
| 76 | + foreach ($categories as $category) { |
|
| 77 | 77 | $insertQuery = (new Insert('article_categories'))->values([ |
| 78 | 78 | 'article_uuid' => $articleId, |
| 79 | 79 | 'category_uuid' => $category->category_uuid |