@@ -6,15 +6,15 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public function up() |
| 8 | 8 | { |
| 9 | - $this->table('article_posts', ['id' => false]) |
|
| 10 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
| 9 | + $this->table('article_posts', [ 'id' => false ]) |
|
| 10 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
| 11 | 11 | ->addColumn('title', 'text') |
| 12 | 12 | ->addColumn('body', 'text') |
| 13 | 13 | ->addColumn('lead', 'text') |
| 14 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
| 15 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
| 16 | - ->addColumn('has_layout', 'boolean', ['default' => true]) |
|
| 17 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
| 14 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
| 15 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
| 16 | + ->addColumn('has_layout', 'boolean', [ 'default' => true ]) |
|
| 17 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
| 18 | 18 | ->create(); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -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,22 +34,22 @@ discard block |
||
| 34 | 34 | public function getPaginationSelect() |
| 35 | 35 | { |
| 36 | 36 | return $this->getSql()->select() |
| 37 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
| 37 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
| 38 | 38 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
| 39 | - ->join('category', 'articles.category_uuid = category.category_uuid', ['category_name' => 'name'], 'left') |
|
| 40 | - ->where(['articles.type' => ArticleType::POST]) |
|
| 41 | - ->order(['created_at' => 'desc']); |
|
| 39 | + ->join('category', 'articles.category_uuid = category.category_uuid', [ 'category_name' => 'name' ], 'left') |
|
| 40 | + ->where([ 'articles.type' => ArticleType::POST ]) |
|
| 41 | + ->order([ 'created_at' => 'desc' ]); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function get($id) |
| 45 | 45 | { |
| 46 | 46 | $select = $this->getSql()->select() |
| 47 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout']) |
|
| 47 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout' ]) |
|
| 48 | 48 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
| 49 | 49 | ->join('category', 'category.category_uuid = articles.category_uuid', |
| 50 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left') |
|
| 51 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
| 52 | - ->where(['articles.article_id' => $id]); |
|
| 50 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left') |
|
| 51 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
| 52 | + ->where([ 'articles.article_id' => $id ]); |
|
| 53 | 53 | |
| 54 | 54 | return $this->selectWith($select)->current(); |
| 55 | 55 | } |
@@ -58,16 +58,16 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $select = $this->getSql()->select() |
| 60 | 60 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
| 61 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_slug' => 'slug']) |
|
| 62 | - ->where(['articles.status' => 1]) |
|
| 61 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_slug' => 'slug' ]) |
|
| 62 | + ->where([ 'articles.status' => 1 ]) |
|
| 63 | 63 | ->limit(1); |
| 64 | 64 | |
| 65 | - if($direction > 0) { |
|
| 65 | + if ($direction > 0) { |
|
| 66 | 66 | $select->where->greaterThan('published_at', $publishedAt); |
| 67 | - $select->order(['published_at' => 'asc']); |
|
| 68 | - } elseif($direction < 0) { |
|
| 67 | + $select->order([ 'published_at' => 'asc' ]); |
|
| 68 | + } elseif ($direction < 0) { |
|
| 69 | 69 | $select->where->lessThan('published_at', $publishedAt); |
| 70 | - $select->order(['published_at' => 'desc']); |
|
| 70 | + $select->order([ 'published_at' => 'desc' ]); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $this->selectWith($select)->current(); |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | public function getBySlug($slug) |
| 77 | 77 | { |
| 78 | 78 | $select = $this->getSql()->select() |
| 79 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
| 79 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
| 80 | 80 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
| 81 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_name' => 'name', 'category_slug' => 'slug']) |
|
| 82 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
| 83 | - ->where(['articles.slug' => $slug, 'articles.status' => 1]); |
|
| 81 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
| 82 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
| 83 | + ->where([ 'articles.slug' => $slug, 'articles.status' => 1 ]); |
|
| 84 | 84 | |
| 85 | 85 | return $this->selectWith($select)->current(); |
| 86 | 86 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function getAll() |
| 89 | 89 | { |
| 90 | 90 | $select = $this->getSql()->select() |
| 91 | - ->join('articles', 'article_posts.article_uuid = articles.article_uuid', ['article_id', 'slug']); |
|
| 91 | + ->join('articles', 'article_posts.article_uuid = articles.article_uuid', [ 'article_id', 'slug' ]); |
|
| 92 | 92 | |
| 93 | 93 | return $this->selectWith($select); |
| 94 | 94 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $select = $this->getSql()->select() |
| 99 | 99 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
| 100 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['first_name', 'last_name']) |
|
| 100 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'first_name', 'last_name' ]) |
|
| 101 | 101 | ->join('category', 'category.category_uuid = articles.category_uuid', |
| 102 | - ['category_name' => 'name', 'category_id', 'category_slug' => 'slug']) |
|
| 103 | - ->where(['articles.status' => 1]) |
|
| 104 | - ->order(['articles.published_at' => 'desc']) |
|
| 102 | + [ 'category_name' => 'name', 'category_id', 'category_slug' => 'slug' ]) |
|
| 103 | + ->where([ 'articles.status' => 1 ]) |
|
| 104 | + ->order([ 'articles.published_at' => 'desc' ]) |
|
| 105 | 105 | ->limit($limit); |
| 106 | 106 | |
| 107 | 107 | return $this->selectWith($select); |
@@ -12,43 +12,43 @@ |
||
| 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' => 100000]], |
|
| 33 | + [ 'name' => 'NotEmpty' ], |
|
| 34 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100000 ] ], |
|
| 35 | 35 | ], |
| 36 | 36 | ]); |
| 37 | 37 | |
| 38 | 38 | $inputFilter->add([ |
| 39 | 39 | 'name' => 'lead', |
| 40 | 40 | 'required' => true, |
| 41 | - 'filters' => [['name' => 'StringTrim']], |
|
| 41 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 42 | 42 | 'validators' => [ |
| 43 | - ['name' => 'NotEmpty'], |
|
| 44 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 50000]], |
|
| 43 | + [ 'name' => 'NotEmpty' ], |
|
| 44 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 50000 ] ], |
|
| 45 | 45 | ], |
| 46 | 46 | ]); |
| 47 | 47 | |
| 48 | 48 | $inputFilter->add([ |
| 49 | 49 | 'name' => 'has_layout', |
| 50 | 50 | 'required' => false, |
| 51 | - 'filters' => [['name' => 'Boolean']], |
|
| 51 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 52 | 52 | ]); |
| 53 | 53 | |
| 54 | 54 | $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 Web\Action; |
| 6 | 6 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $page = $this->pageService->getHomepage(); |
| 50 | 50 | |
| 51 | - return new HtmlResponse($this->template->render('web::home', ['page' => $page, 'layout' => 'layout/web'])); |
|
| 51 | + return new HtmlResponse($this->template->render('web::home', [ 'page' => $page, 'layout' => 'layout/web' ])); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Action; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Factory\Action; |
| 6 | 6 | |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function getActivePage($urlSlug) |
| 35 | 35 | { |
| 36 | - return $this->select(['slug' => $urlSlug, 'is_active' => true]); |
|
| 36 | + return $this->select([ 'slug' => $urlSlug, 'is_active' => true ]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ 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\Controller; |
| 6 | 6 | |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | public function index(): \Psr\Http\Message\ResponseInterface |
| 58 | 58 | { |
| 59 | 59 | $params = $this->request->getQueryParams(); |
| 60 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
| 61 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
| 60 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
| 61 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
| 62 | 62 | |
| 63 | 63 | $discussions = $this->discussionService->fetchAllArticles($page, $limit); |
| 64 | 64 | |
| 65 | - return new HtmlResponse($this->template->render('article::discussion/index', ['list' => $discussions, 'layout' => 'layout/admin'])); |
|
| 65 | + return new HtmlResponse($this->template->render('article::discussion/index', [ 'list' => $discussions, 'layout' => 'layout/admin' ])); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return \Psr\Http\Message\ResponseInterface |
| 74 | 74 | */ |
| 75 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
| 75 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
| 76 | 76 | { |
| 77 | 77 | $id = $this->request->getAttribute('id'); |
| 78 | 78 | $discussion = $this->discussionService->fetchSingleArticle($id); |
| 79 | 79 | $categories = $this->categoryService->getAll(); |
| 80 | 80 | |
| 81 | - if($this->request->getParsedBody()) { |
|
| 82 | - $discussion = (object)($this->request->getParsedBody() + (array)$discussion); |
|
| 81 | + if ($this->request->getParsedBody()) { |
|
| 82 | + $discussion = (object) ($this->request->getParsedBody() + (array) $discussion); |
|
| 83 | 83 | $discussion->article_id = $id; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -98,16 +98,16 @@ discard block |
||
| 98 | 98 | $data = $this->request->getParsedBody(); |
| 99 | 99 | $user = $this->session->getStorage()->user; |
| 100 | 100 | |
| 101 | - if($id) { |
|
| 101 | + if ($id) { |
|
| 102 | 102 | $this->discussionService->updateArticle($data, $id); |
| 103 | 103 | } else { |
| 104 | 104 | $this->discussionService->createArticle($user, $data); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - catch(FilterException $fe) { |
|
| 107 | + catch (FilterException $fe) { |
|
| 108 | 108 | return $this->edit($fe->getArrayMessages()); |
| 109 | 109 | } |
| 110 | - catch(\Exception $e) { |
|
| 110 | + catch (\Exception $e) { |
|
| 111 | 111 | throw $e; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | try { |
| 120 | 120 | $this->discussionService->deleteArticle($this->request->getAttribute('id')); |
| 121 | 121 | } |
| 122 | - catch(\Exception $e) { |
|
| 122 | + catch (\Exception $e) { |
|
| 123 | 123 | throw $e; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | public function testIndexMethodShouldReturnHtmlResponse() |
| 8 | 8 | { |
| 9 | 9 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 10 | - ->setMethods(['render']) |
|
| 10 | + ->setMethods([ 'render' ]) |
|
| 11 | 11 | ->getMockForAbstractClass(); |
| 12 | 12 | $template->expects(static::once()) |
| 13 | 13 | ->method('render') |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $sessionStorage = new \Zend\Session\Storage\ArrayStorage(); |
| 44 | 44 | $sessionStorage->user = $user; |
| 45 | 45 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 46 | - ->setMethods(['render']) |
|
| 46 | + ->setMethods([ 'render' ]) |
|
| 47 | 47 | ->getMockForAbstractClass(); |
| 48 | 48 | $template->expects(static::once()) |
| 49 | 49 | ->method('render') |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $sessionStorage = new \Zend\Session\Storage\ArrayStorage(); |
| 81 | 81 | $sessionStorage->user = $user; |
| 82 | 82 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 83 | - ->setMethods(['render']) |
|
| 83 | + ->setMethods([ 'render' ]) |
|
| 84 | 84 | ->getMockForAbstractClass(); |
| 85 | 85 | $template->expects(static::once()) |
| 86 | 86 | ->method('render') |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $request = new \Zend\Diactoros\ServerRequest(); |
| 100 | 100 | $request = $request->withAttribute('action', 'edit'); |
| 101 | 101 | $request = $request->withAttribute('id', 1); |
| 102 | - $request = $request->withParsedBody(['discussion' => 'test']); |
|
| 102 | + $request = $request->withParsedBody([ 'discussion' => 'test' ]); |
|
| 103 | 103 | $response = new \Zend\Diactoros\Response(); |
| 104 | 104 | $discussionController = new \Article\Controller\DiscussionController( |
| 105 | 105 | $template, |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | ->will(static::returnValue('http://unfinished.dev/admin')); |
| 136 | 136 | $request = new \Zend\Diactoros\ServerRequest(); |
| 137 | 137 | $request = $request->withAttribute('action', 'save'); |
| 138 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 138 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 139 | 139 | $response = new \Zend\Diactoros\Response(); |
| 140 | 140 | $discussionController = new \Article\Controller\DiscussionController( |
| 141 | 141 | $template, |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $request = new \Zend\Diactoros\ServerRequest(); |
| 175 | 175 | $request = $request->withAttribute('action', 'save'); |
| 176 | 176 | $request = $request->withAttribute('id', 2); |
| 177 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 177 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 178 | 178 | $response = new \Zend\Diactoros\Response(); |
| 179 | 179 | $discussionController = new \Article\Controller\DiscussionController( |
| 180 | 180 | $template, |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | ->getMock(); |
| 208 | 208 | $discussionService->expects(static::once()) |
| 209 | 209 | ->method('updateArticle') |
| 210 | - ->willThrowException(new \Core\Exception\FilterException(['test error'])); |
|
| 210 | + ->willThrowException(new \Core\Exception\FilterException([ 'test error' ])); |
|
| 211 | 211 | $categoryService = $this->getMockBuilder(\Category\Service\CategoryService::class) |
| 212 | 212 | ->disableOriginalConstructor() |
| 213 | 213 | ->getMock(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $request = new \Zend\Diactoros\ServerRequest(); |
| 217 | 217 | $request = $request->withAttribute('action', 'save'); |
| 218 | 218 | $request = $request->withAttribute('id', 2); |
| 219 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 219 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 220 | 220 | $response = new \Zend\Diactoros\Response(); |
| 221 | 221 | $discussionController = new \Article\Controller\DiscussionController( |
| 222 | 222 | $template, |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $request = new \Zend\Diactoros\ServerRequest(); |
| 261 | 261 | $request = $request->withAttribute('action', 'save'); |
| 262 | 262 | $request = $request->withAttribute('id', 2); |
| 263 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 263 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 264 | 264 | $response = new \Zend\Diactoros\Response(); |
| 265 | 265 | $discussionController = new \Article\Controller\DiscussionController( |
| 266 | 266 | $template, |