@@ -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 | |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | $select->where->notEqualTo('slug', 'videos'); |
| 87 | 87 | $select->where->notEqualTo('slug', 'events'); |
| 88 | 88 | |
| 89 | - if($inHomepage !== null) { |
|
| 90 | - $select->where(['is_in_homepage' => $inHomepage]); |
|
| 89 | + if ($inHomepage !== null) { |
|
| 90 | + $select->where([ 'is_in_homepage' => $inHomepage ]); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if($inCategoryList !== null) { |
|
| 94 | - $select->where(['is_in_category_list' => $inCategoryList]); |
|
| 93 | + if ($inCategoryList !== null) { |
|
| 94 | + $select->where([ 'is_in_category_list' => $inCategoryList ]); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if($limit) { |
|
| 97 | + if ($limit) { |
|
| 98 | 98 | $select->limit($limit); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if($order) { |
|
| 101 | + if ($order) { |
|
| 102 | 102 | $select->order($order); |
| 103 | 103 | } else { |
| 104 | 104 | $select->order(new Expression('rand()')); |
@@ -22,21 +22,21 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * |
| 24 | 24 | * |
| 25 | - * @var Template |
|
| 25 | + * @var Template |
|
| 26 | 26 | */ |
| 27 | 27 | private $template; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * |
| 31 | 31 | * |
| 32 | - * @var Router |
|
| 32 | + * @var Router |
|
| 33 | 33 | */ |
| 34 | 34 | private $router; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * |
| 38 | 38 | * |
| 39 | - * @var CategoryService |
|
| 39 | + * @var CategoryService |
|
| 40 | 40 | */ |
| 41 | 41 | private $categoryService; |
| 42 | 42 | |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | public function index() : \Psr\Http\Message\ResponseInterface |
| 61 | 61 | { |
| 62 | 62 | $params = $this->request->getQueryParams(); |
| 63 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
| 64 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
| 63 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
| 64 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
| 65 | 65 | |
| 66 | 66 | $categories = $this->categoryService->getPagination($page, $limit); |
| 67 | 67 | |
| 68 | - return new HtmlResponse($this->template->render('category::index/index', ['list' => $categories, 'layout' => 'layout/admin'])); |
|
| 68 | + return new HtmlResponse($this->template->render('category::index/index', [ 'list' => $categories, 'layout' => 'layout/admin' ])); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return \Psr\Http\Message\ResponseInterface |
| 75 | 75 | */ |
| 76 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
| 76 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
| 77 | 77 | { |
| 78 | 78 | $id = $this->request->getAttribute('id'); |
| 79 | 79 | $category = $this->categoryService->getCategory($id); |
| 80 | 80 | |
| 81 | - if($this->request->getParsedBody()) { |
|
| 82 | - $category = (object)($this->request->getParsedBody() + (array)$category); |
|
| 81 | + if ($this->request->getParsedBody()) { |
|
| 82 | + $category = (object) ($this->request->getParsedBody() + (array) $category); |
|
| 83 | 83 | $category->category_id = $id; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -96,37 +96,37 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function save() |
| 98 | 98 | { |
| 99 | - try{ |
|
| 99 | + try { |
|
| 100 | 100 | $id = $this->request->getAttribute('id'); |
| 101 | 101 | $data = $this->request->getParsedBody(); |
| 102 | 102 | $data += (new Request())->getFiles()->toArray(); |
| 103 | 103 | |
| 104 | - if($id) { |
|
| 104 | + if ($id) { |
|
| 105 | 105 | $this->categoryService->updateCategory($data, $id); |
| 106 | 106 | } |
| 107 | - else{ |
|
| 107 | + else { |
|
| 108 | 108 | $this->categoryService->createCategory($data); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
| 112 | 112 | } |
| 113 | - catch(FilterException $fe){ |
|
| 113 | + catch (FilterException $fe) { |
|
| 114 | 114 | return $this->edit($fe->getArrayMessages()); |
| 115 | 115 | } |
| 116 | - catch(\Exception $e){ |
|
| 116 | + catch (\Exception $e) { |
|
| 117 | 117 | throw $e; |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function delete() |
| 122 | 122 | { |
| 123 | - try{ |
|
| 123 | + try { |
|
| 124 | 124 | $id = $this->request->getAttribute('id'); |
| 125 | 125 | $this->categoryService->delete($id); |
| 126 | 126 | |
| 127 | 127 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
| 128 | 128 | } |
| 129 | - catch(\Exception $e){ |
|
| 129 | + catch (\Exception $e) { |
|
| 130 | 130 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -103,17 +103,14 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | if($id) { |
| 105 | 105 | $this->categoryService->updateCategory($data, $id); |
| 106 | - } |
|
| 107 | - else{ |
|
| 106 | + } else{ |
|
| 108 | 107 | $this->categoryService->createCategory($data); |
| 109 | 108 | } |
| 110 | 109 | |
| 111 | 110 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
| 112 | - } |
|
| 113 | - catch(FilterException $fe){ |
|
| 111 | + } catch(FilterException $fe){ |
|
| 114 | 112 | return $this->edit($fe->getArrayMessages()); |
| 115 | - } |
|
| 116 | - catch(\Exception $e){ |
|
| 113 | + } catch(\Exception $e){ |
|
| 117 | 114 | throw $e; |
| 118 | 115 | } |
| 119 | 116 | } |
@@ -125,8 +122,7 @@ discard block |
||
| 125 | 122 | $this->categoryService->delete($id); |
| 126 | 123 | |
| 127 | 124 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
| 128 | - } |
|
| 129 | - catch(\Exception $e){ |
|
| 125 | + } catch(\Exception $e){ |
|
| 130 | 126 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
| 131 | 127 | } |
| 132 | 128 | } |
@@ -12,17 +12,17 @@ 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 | [ |
| 20 | 20 | 'name' => 'name', |
| 21 | 21 | 'required' => true, |
| 22 | - 'filters' => [['name' => 'StringTrim']], |
|
| 22 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 23 | 23 | 'validators' => [ |
| 24 | - ['name' => 'NotEmpty'], |
|
| 25 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 500]], |
|
| 24 | + [ 'name' => 'NotEmpty' ], |
|
| 25 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 500 ] ], |
|
| 26 | 26 | ], |
| 27 | 27 | ] |
| 28 | 28 | ); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | [ |
| 32 | 32 | 'name' => 'slug', |
| 33 | 33 | 'required' => true, |
| 34 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
| 34 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
| 35 | 35 | 'validators' => [ |
| 36 | - ['name' => 'NotEmpty'], |
|
| 37 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
| 36 | + [ 'name' => 'NotEmpty' ], |
|
| 37 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
| 38 | 38 | ], |
| 39 | 39 | ] |
| 40 | 40 | ); |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | [ |
| 44 | 44 | 'name' => 'title', |
| 45 | 45 | 'required' => false, |
| 46 | - 'filters' => [['name' => 'StringTrim']], |
|
| 46 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 47 | 47 | 'validators' => [ |
| 48 | - ['name' => 'NotEmpty'], |
|
| 49 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
| 48 | + [ 'name' => 'NotEmpty' ], |
|
| 49 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
| 50 | 50 | ], |
| 51 | 51 | ] |
| 52 | 52 | ); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | [ |
| 56 | 56 | 'name' => 'description', |
| 57 | 57 | 'required' => false, |
| 58 | - 'filters' => [['name' => 'StringTrim']], |
|
| 58 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 59 | 59 | 'validators' => [ |
| 60 | - ['name' => 'NotEmpty'], |
|
| 61 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 1000]], |
|
| 60 | + [ 'name' => 'NotEmpty' ], |
|
| 61 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 1000 ] ], |
|
| 62 | 62 | ], |
| 63 | 63 | ] |
| 64 | 64 | ); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | [ |
| 68 | 68 | 'name' => 'is_in_homepage', |
| 69 | 69 | 'required' => false, |
| 70 | - 'filters' => [['name' => 'Boolean']], |
|
| 70 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 71 | 71 | ] |
| 72 | 72 | ); |
| 73 | 73 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | [ |
| 76 | 76 | 'name' => 'is_in_category_list', |
| 77 | 77 | 'required' => false, |
| 78 | - 'filters' => [['name' => 'Boolean']], |
|
| 78 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 79 | 79 | ] |
| 80 | 80 | ); |
| 81 | 81 | |
@@ -21,21 +21,21 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * |
| 23 | 23 | * |
| 24 | - * @var Template |
|
| 24 | + * @var Template |
|
| 25 | 25 | */ |
| 26 | 26 | private $template; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * |
| 30 | 30 | * |
| 31 | - * @var VideoService |
|
| 31 | + * @var VideoService |
|
| 32 | 32 | */ |
| 33 | 33 | private $videoService; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @var CategoryService |
|
| 38 | + * @var CategoryService |
|
| 39 | 39 | */ |
| 40 | 40 | private $categoryService; |
| 41 | 41 | |
@@ -20,14 +20,14 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * |
| 22 | 22 | * |
| 23 | - * @var Template |
|
| 23 | + * @var Template |
|
| 24 | 24 | */ |
| 25 | 25 | private $template; |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * |
| 29 | 29 | * |
| 30 | - * @var PageService |
|
| 30 | + * @var PageService |
|
| 31 | 31 | */ |
| 32 | 32 | private $pageService; |
| 33 | 33 | |
@@ -21,21 +21,21 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * |
| 23 | 23 | * |
| 24 | - * @var Template |
|
| 24 | + * @var Template |
|
| 25 | 25 | */ |
| 26 | 26 | private $template; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * |
| 30 | 30 | * |
| 31 | - * @var EventService |
|
| 31 | + * @var EventService |
|
| 32 | 32 | */ |
| 33 | 33 | private $eventService; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @var CategoryService |
|
| 38 | + * @var CategoryService |
|
| 39 | 39 | */ |
| 40 | 40 | private $categoryService; |
| 41 | 41 | |
@@ -20,14 +20,14 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * |
| 22 | 22 | * |
| 23 | - * @var Template |
|
| 23 | + * @var Template |
|
| 24 | 24 | */ |
| 25 | 25 | private $template; |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * |
| 29 | 29 | * |
| 30 | - * @var PostService |
|
| 30 | + * @var PostService |
|
| 31 | 31 | */ |
| 32 | 32 | private $postService; |
| 33 | 33 | |
@@ -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 | |
@@ -76,21 +76,21 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $eventSlug = $request->getAttribute('event_slug'); |
| 78 | 78 | $event = $this->eventService->fetchEventBySlug($eventSlug); |
| 79 | - $attendees = []; |
|
| 79 | + $attendees = [ ]; |
|
| 80 | 80 | |
| 81 | - if(!$event) { |
|
| 81 | + if (!$event) { |
|
| 82 | 82 | return $next($request, $response); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Fetch going ppl |
| 86 | 86 | try { |
| 87 | - if(strpos($event->event_url, 'meetup.com') !== false) { |
|
| 87 | + if (strpos($event->event_url, 'meetup.com') !== false) { |
|
| 88 | 88 | $parts = explode('/', $event->event_url); |
| 89 | - $attendees = $this->meetupService->getMeetupAttendees($parts[count($parts) - 2]); |
|
| 89 | + $attendees = $this->meetupService->getMeetupAttendees($parts[ count($parts) - 2 ]); |
|
| 90 | 90 | shuffle($attendees); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | - catch(\Exception $e) { |
|
| 93 | + catch (\Exception $e) { |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | return new HtmlResponse( |
@@ -89,8 +89,7 @@ |
||
| 89 | 89 | $attendees = $this->meetupService->getMeetupAttendees($parts[count($parts) - 2]); |
| 90 | 90 | shuffle($attendees); |
| 91 | 91 | } |
| 92 | - } |
|
| 93 | - catch(\Exception $e) { |
|
| 92 | + } catch(\Exception $e) { |
|
| 94 | 93 | } |
| 95 | 94 | |
| 96 | 95 | return new HtmlResponse( |
@@ -21,21 +21,21 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * |
| 23 | 23 | * |
| 24 | - * @var Template |
|
| 24 | + * @var Template |
|
| 25 | 25 | */ |
| 26 | 26 | private $template; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * |
| 30 | 30 | * |
| 31 | - * @var EventService |
|
| 31 | + * @var EventService |
|
| 32 | 32 | */ |
| 33 | 33 | private $eventService; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @var CategoryService |
|
| 38 | + * @var CategoryService |
|
| 39 | 39 | */ |
| 40 | 40 | private $categoryService; |
| 41 | 41 | |
@@ -20,14 +20,14 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * |
| 22 | 22 | * |
| 23 | - * @var Template |
|
| 23 | + * @var Template |
|
| 24 | 24 | */ |
| 25 | 25 | private $template; |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * |
| 29 | 29 | * |
| 30 | - * @var PageService $pageService |
|
| 30 | + * @var PageService $pageService |
|
| 31 | 31 | */ |
| 32 | 32 | private $pageService; |
| 33 | 33 | |