@@ -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 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $article = $this->postService->getHomepage(); |
49 | 49 | |
50 | - if(!$article) { |
|
50 | + if (!$article) { |
|
51 | 51 | throw new \Exception('You need to set homepage!', 404); |
52 | 52 | } |
53 | 53 |
@@ -29,16 +29,16 @@ |
||
29 | 29 | |
30 | 30 | public function getHeaderMenu() |
31 | 31 | { |
32 | - return $this->menuService->getNestedAll(true, ['is_in_header' => true]); |
|
32 | + return $this->menuService->getNestedAll(true, [ 'is_in_header' => true ]); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function getFooterMenu() |
36 | 36 | { |
37 | - return $this->menuService->getNestedAll(true, ['is_in_footer' => true]); |
|
37 | + return $this->menuService->getNestedAll(true, [ 'is_in_footer' => true ]); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getSideMenu() |
41 | 41 | { |
42 | - return $this->menuService->getNestedAll(true, ['is_in_side' => true]); |
|
42 | + return $this->menuService->getNestedAll(true, [ 'is_in_side' => true ]); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | \ No newline at end of file |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | $this->adapter = $adapter; |
16 | 16 | } |
17 | 17 | |
18 | - public function selectAll($isActive = null, $filter = []) |
|
18 | + public function selectAll($isActive = null, $filter = [ ]) |
|
19 | 19 | { |
20 | 20 | $select = $this->getSql()->select() |
21 | - ->join('category', 'menu.category_uuid = category.category_uuid', ['category_name' => 'name', 'category_slug' => 'slug'], 'left') |
|
22 | - ->join('articles', 'articles.article_uuid = menu.article_uuid', ['article_id', 'article_slug' => 'slug'], 'left') |
|
23 | - ->order(['order_no' => 'asc']); |
|
21 | + ->join('category', 'menu.category_uuid = category.category_uuid', [ 'category_name' => 'name', 'category_slug' => 'slug' ], 'left') |
|
22 | + ->join('articles', 'articles.article_uuid = menu.article_uuid', [ 'article_id', 'article_slug' => 'slug' ], 'left') |
|
23 | + ->order([ 'order_no' => 'asc' ]); |
|
24 | 24 | |
25 | - if($isActive !== null) { |
|
26 | - $select->where(['is_active' => $isActive]); |
|
25 | + if ($isActive !== null) { |
|
26 | + $select->where([ 'is_active' => $isActive ]); |
|
27 | 27 | } |
28 | 28 | |
29 | - if($filter) { |
|
30 | - if(isset($filter['is_in_header'])) { |
|
31 | - $select->where(['is_in_header' => $filter['is_in_header']]); |
|
32 | - } elseif(isset($filter['is_in_footer'])) { |
|
33 | - $select->where(['is_in_footer' => $filter['is_in_footer']]); |
|
34 | - } elseif(isset($filter['is_in_side'])) { |
|
35 | - $select->where(['is_in_side' => $filter['is_in_side']]); |
|
29 | + if ($filter) { |
|
30 | + if (isset($filter[ 'is_in_header' ])) { |
|
31 | + $select->where([ 'is_in_header' => $filter[ 'is_in_header' ] ]); |
|
32 | + } elseif (isset($filter[ 'is_in_footer' ])) { |
|
33 | + $select->where([ 'is_in_footer' => $filter[ 'is_in_footer' ] ]); |
|
34 | + } elseif (isset($filter[ 'is_in_side' ])) { |
|
35 | + $select->where([ 'is_in_side' => $filter[ 'is_in_side' ] ]); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function updateMenuItem($data, $id) |
50 | 50 | { |
51 | - $this->update($data, ['menu_id' => $id]); |
|
51 | + $this->update($data, [ 'menu_id' => $id ]); |
|
52 | 52 | |
53 | 53 | return $id; |
54 | 54 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | public function get($id) |
57 | 57 | { |
58 | 58 | $select = $this->getSql()->select() |
59 | - ->join('articles', 'articles.article_uuid = menu.article_uuid', ['article_id'], 'left') |
|
60 | - ->join('category', 'category.category_uuid = menu.category_uuid', ['category_id'], 'left') |
|
61 | - ->where(['menu_id' => $id]); |
|
59 | + ->join('articles', 'articles.article_uuid = menu.article_uuid', [ 'article_id' ], 'left') |
|
60 | + ->join('category', 'category.category_uuid = menu.category_uuid', [ 'category_id' ], 'left') |
|
61 | + ->where([ 'menu_id' => $id ]); |
|
62 | 62 | |
63 | 63 | return $this->selectWith($select)->current(); |
64 | 64 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | public function forSelect() |
67 | 67 | { |
68 | 68 | $select = $this->getSql()->select() |
69 | - ->columns(['menu_id', 'title', 'is_active']) |
|
70 | - ->order(['is_active' => 'desc']); |
|
69 | + ->columns([ 'menu_id', 'title', 'is_active' ]) |
|
70 | + ->order([ 'is_active' => 'desc' ]); |
|
71 | 71 | |
72 | 72 | return $this->selectWith($select); |
73 | 73 | } |
@@ -28,26 +28,26 @@ discard block |
||
28 | 28 | private function unflattenArray(array $flatArray) |
29 | 29 | { |
30 | 30 | $flatArray = array_reverse($flatArray); |
31 | - $refs = []; |
|
32 | - $result = []; |
|
31 | + $refs = [ ]; |
|
32 | + $result = [ ]; |
|
33 | 33 | |
34 | - while(count($flatArray) > 0) { |
|
35 | - for($i = count($flatArray) - 1; $i >= 0; $i--) { |
|
36 | - if(!isset($flatArray[$i]['children'])) { |
|
37 | - $flatArray[$i]['children'] = []; |
|
34 | + while (count($flatArray) > 0) { |
|
35 | + for ($i = count($flatArray) - 1; $i >= 0; $i--) { |
|
36 | + if (!isset($flatArray[ $i ][ 'children' ])) { |
|
37 | + $flatArray[ $i ][ 'children' ] = [ ]; |
|
38 | 38 | } |
39 | 39 | |
40 | - if(!$flatArray[$i]["parent_id"]) { |
|
41 | - $result[$flatArray[$i]["menu_id"]] = $flatArray[$i]; |
|
42 | - $refs[$flatArray[$i]["menu_id"]] = &$result[$flatArray[$i]["menu_id"]]; |
|
43 | - unset($flatArray[$i]); |
|
40 | + if (!$flatArray[ $i ][ "parent_id" ]) { |
|
41 | + $result[ $flatArray[ $i ][ "menu_id" ] ] = $flatArray[ $i ]; |
|
42 | + $refs[ $flatArray[ $i ][ "menu_id" ] ] = &$result[ $flatArray[ $i ][ "menu_id" ] ]; |
|
43 | + unset($flatArray[ $i ]); |
|
44 | 44 | $flatArray = array_values($flatArray); |
45 | - } else if($flatArray[$i]["parent_id"] != 0) { |
|
46 | - if(array_key_exists($flatArray[$i]["parent_id"], $refs)) { |
|
47 | - $o = $flatArray[$i]; |
|
48 | - $refs[$flatArray[$i]["menu_id"]] = $o; |
|
49 | - $refs[$flatArray[$i]["parent_id"]]["children"][] = &$refs[$flatArray[$i]["menu_id"]]; |
|
50 | - unset($flatArray[$i]); |
|
45 | + } else if ($flatArray[ $i ][ "parent_id" ] != 0) { |
|
46 | + if (array_key_exists($flatArray[ $i ][ "parent_id" ], $refs)) { |
|
47 | + $o = $flatArray[ $i ]; |
|
48 | + $refs[ $flatArray[ $i ][ "menu_id" ] ] = $o; |
|
49 | + $refs[ $flatArray[ $i ][ "parent_id" ] ][ "children" ][ ] = &$refs[ $flatArray[ $i ][ "menu_id" ] ]; |
|
50 | + unset($flatArray[ $i ]); |
|
51 | 51 | $flatArray = array_values($flatArray); |
52 | 52 | } |
53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $this->postService = $postService; |
66 | 66 | } |
67 | 67 | |
68 | - public function getNestedAll($isActive = null, $filter = []) |
|
68 | + public function getNestedAll($isActive = null, $filter = [ ]) |
|
69 | 69 | { |
70 | 70 | $items = $this->menuMapper->selectAll($isActive, $filter)->toArray(); |
71 | 71 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | { |
82 | 82 | $data = $this->filterMenuItem($data); |
83 | 83 | |
84 | - $data['menu_id'] = Uuid::uuid1()->toString(); |
|
85 | - $data['menu_uuid'] = (new MysqlUuid($data['menu_id']))->toFormat(new Binary); |
|
84 | + $data[ 'menu_id' ] = Uuid::uuid1()->toString(); |
|
85 | + $data[ 'menu_uuid' ] = (new MysqlUuid($data[ 'menu_id' ]))->toFormat(new Binary); |
|
86 | 86 | |
87 | 87 | return $this->menuMapper->insertMenuItem($data); |
88 | 88 | } |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | |
97 | 97 | public function delete($id) |
98 | 98 | { |
99 | - $children = $this->menuMapper->select(['parent_id' => $id]); |
|
99 | + $children = $this->menuMapper->select([ 'parent_id' => $id ]); |
|
100 | 100 | |
101 | - if($children->count()) { |
|
101 | + if ($children->count()) { |
|
102 | 102 | throw new \Exception('This Menu Item has child items', 400); |
103 | 103 | } |
104 | 104 | |
105 | - return $this->menuMapper->delete(['menu_id' => $id]); |
|
105 | + return $this->menuMapper->delete([ 'menu_id' => $id ]); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function getForSelect() |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | public function updateMenuOrder($menuOrder) |
114 | 114 | { |
115 | - if(!$menuOrder) { |
|
115 | + if (!$menuOrder) { |
|
116 | 116 | return true; |
117 | 117 | } |
118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $this->updateLevel(null, $menuOrder, $orderNo); |
123 | 123 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->commit(); |
124 | 124 | } |
125 | - catch(\Exception $e) { |
|
125 | + catch (\Exception $e) { |
|
126 | 126 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->rollback(); |
127 | 127 | |
128 | 128 | throw $e; |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | |
134 | 134 | private function updateLevel($parentId = null, $children, &$orderNo) |
135 | 135 | { |
136 | - foreach($children as $v) { |
|
137 | - if(isset($v->children)) { |
|
138 | - $this->menuMapper->update(['order_no' => $orderNo++, 'parent_id' => $parentId], ['menu_id' => $v->id]); |
|
136 | + foreach ($children as $v) { |
|
137 | + if (isset($v->children)) { |
|
138 | + $this->menuMapper->update([ 'order_no' => $orderNo++, 'parent_id' => $parentId ], [ 'menu_id' => $v->id ]); |
|
139 | 139 | $this->updateLevel($v->id, $v->children, $orderNo); |
140 | 140 | } else { |
141 | - $this->menuMapper->update(['order_no' => $orderNo++, 'parent_id' => $parentId], ['menu_id' => $v->id]); |
|
141 | + $this->menuMapper->update([ 'order_no' => $orderNo++, 'parent_id' => $parentId ], [ 'menu_id' => $v->id ]); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -147,30 +147,30 @@ discard block |
||
147 | 147 | { |
148 | 148 | $filter = $this->menuFilter->getInputFilter()->setData($data); |
149 | 149 | |
150 | - if(!$filter->isValid()) { |
|
150 | + if (!$filter->isValid()) { |
|
151 | 151 | throw new FilterException($filter->getMessages()); |
152 | 152 | } |
153 | 153 | |
154 | - if(count(array_filter([$data['article_id'], $data['category_id'], $data['href']])) > 1) { |
|
154 | + if (count(array_filter([ $data[ 'article_id' ], $data[ 'category_id' ], $data[ 'href' ] ])) > 1) { |
|
155 | 155 | throw new \Exception('You need to set only one link. Post, Category or Href.'); |
156 | 156 | } |
157 | 157 | |
158 | 158 | $data = $filter->getValues(); |
159 | 159 | |
160 | - if($data['article_id']) { |
|
161 | - $article = $this->postService->fetchSingleArticle($data['article_id']); |
|
162 | - $data['article_uuid'] = $article->article_uuid; |
|
163 | - $data['category_uuid'] = null; |
|
164 | - } elseif($data['category_id']) { |
|
165 | - $category = $this->categoryService->getCategory($data['category_id']); |
|
166 | - $data['category_uuid'] = $category->category_uuid; |
|
167 | - $data['article_uuid'] = null; |
|
160 | + if ($data[ 'article_id' ]) { |
|
161 | + $article = $this->postService->fetchSingleArticle($data[ 'article_id' ]); |
|
162 | + $data[ 'article_uuid' ] = $article->article_uuid; |
|
163 | + $data[ 'category_uuid' ] = null; |
|
164 | + } elseif ($data[ 'category_id' ]) { |
|
165 | + $category = $this->categoryService->getCategory($data[ 'category_id' ]); |
|
166 | + $data[ 'category_uuid' ] = $category->category_uuid; |
|
167 | + $data[ 'article_uuid' ] = null; |
|
168 | 168 | } else { |
169 | - $data['article_uuid'] = null; |
|
170 | - $data['category_uuid'] = null; |
|
169 | + $data[ 'article_uuid' ] = null; |
|
170 | + $data[ 'category_uuid' ] = null; |
|
171 | 171 | } |
172 | 172 | |
173 | - unset($data['article_id'], $data['category_id']); |
|
173 | + unset($data[ 'article_id' ], $data[ 'category_id' ]); |
|
174 | 174 | |
175 | 175 | return $data; |
176 | 176 | } |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function up() |
12 | 12 | { |
13 | - $this->table('article_posts', ['id' => false]) |
|
14 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
13 | + $this->table('article_posts', [ 'id' => false ]) |
|
14 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
15 | 15 | ->addColumn('title', 'text') |
16 | 16 | ->addColumn('body', 'text') |
17 | 17 | ->addColumn('lead', 'text') |
18 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
19 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
20 | - ->addColumn('has_layout', 'boolean', ['default' => true]) |
|
21 | - ->addColumn('is_homepage', 'boolean', ['default' => false]) |
|
22 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
18 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
19 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
20 | + ->addColumn('has_layout', 'boolean', [ 'default' => true ]) |
|
21 | + ->addColumn('is_homepage', 'boolean', [ 'default' => false ]) |
|
22 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
23 | 23 | ->create(); |
24 | 24 | |
25 | 25 | // $this->insertDummyData(); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | private function insertDummyData() |
34 | 34 | { |
35 | - $ids = []; |
|
35 | + $ids = [ ]; |
|
36 | 36 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
37 | - foreach($rows as $r) { |
|
38 | - $ids[] = $r['admin_user_uuid']; |
|
37 | + foreach ($rows as $r) { |
|
38 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $faker = Faker\Factory::create(); |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | $count = rand(25, 300); |
44 | 44 | |
45 | 45 | // Download N images and set it randomly to posts |
46 | - for($i = 0; $i < 5; $i++) { |
|
46 | + for ($i = 0; $i < 5; $i++) { |
|
47 | 47 | $image = $faker->image(); |
48 | 48 | $destination = $upload->getPath(basename($image)); |
49 | 49 | rename($image, $destination); |
50 | - $mainImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
50 | + $mainImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
51 | 51 | |
52 | 52 | $image = $faker->image(); |
53 | 53 | $destination = $upload->getPath(basename($image)); |
54 | 54 | rename($image, $destination); |
55 | - $featuredImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
55 | + $featuredImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
56 | 56 | } |
57 | 57 | |
58 | - for($i = 0; $i < $count; $i++) { |
|
58 | + for ($i = 0; $i < $count; $i++) { |
|
59 | 59 | $id = $faker->uuid; |
60 | 60 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
61 | 61 | $title = $faker->sentence(7, 20); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'article_id' => $id, |
66 | 66 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
67 | 67 | 'status' => 1, |
68 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
68 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
69 | 69 | 'type' => ArticleType::POST |
70 | 70 | ]; |
71 | 71 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | 'title' => $title, |
75 | 75 | 'body' => $faker->paragraph(15), |
76 | 76 | 'lead' => $faker->paragraph(5), |
77 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
78 | - 'featured_img' => $featuredImg[array_rand($featuredImg)] |
|
77 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
78 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ] |
|
79 | 79 | ]; |
80 | 80 | |
81 | 81 | $this->insert('articles', $article); |
@@ -12,30 +12,30 @@ |
||
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' => 'slug', |
20 | 20 | 'required' => true, |
21 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
21 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
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' => 'published_at', |
30 | 30 | 'required' => true, |
31 | - 'filters' => [['name' => 'StringTrim']], |
|
32 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
32 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
33 | 33 | ]); |
34 | 34 | |
35 | 35 | $inputFilter->add([ |
36 | 36 | 'name' => 'status', |
37 | 37 | 'required' => false, |
38 | - 'filters' => [['name' => 'Boolean']], |
|
38 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | $this->inputFilter = $inputFilter; |
@@ -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,18 +34,18 @@ discard block |
||
34 | 34 | public function getPaginationSelect() |
35 | 35 | { |
36 | 36 | return $this->getSql()->select() |
37 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'is_homepage']) |
|
37 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'is_homepage' ]) |
|
38 | 38 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
39 | - ->where(['articles.type' => ArticleType::POST]) |
|
40 | - ->order(['created_at' => 'desc']); |
|
39 | + ->where([ 'articles.type' => ArticleType::POST ]) |
|
40 | + ->order([ 'created_at' => 'desc' ]); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function get($id) |
44 | 44 | { |
45 | 45 | $select = $this->getSql()->select() |
46 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout', 'is_homepage']) |
|
46 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'has_layout', 'is_homepage' ]) |
|
47 | 47 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
48 | - ->where(['articles.article_id' => $id]); |
|
48 | + ->where([ 'articles.article_id' => $id ]); |
|
49 | 49 | |
50 | 50 | return $this->selectWith($select)->current(); |
51 | 51 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $select = $this->getSql()->select() |
56 | 56 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
57 | - ->where(['article_posts.is_homepage' => true, 'articles.status' => 1]); |
|
57 | + ->where([ 'article_posts.is_homepage' => true, 'articles.status' => 1 ]); |
|
58 | 58 | |
59 | 59 | return $this->selectWith($select)->current(); |
60 | 60 | } |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | public function getBySlug($slug) |
63 | 63 | { |
64 | 64 | $select = $this->getSql()->select() |
65 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img']) |
|
65 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img' ]) |
|
66 | 66 | ->join('articles', 'article_posts.article_uuid = articles.article_uuid') |
67 | - ->where(['articles.slug' => $slug, 'articles.status' => 1]); |
|
67 | + ->where([ 'articles.slug' => $slug, 'articles.status' => 1 ]); |
|
68 | 68 | |
69 | 69 | return $this->selectWith($select)->current(); |
70 | 70 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function getAll() |
73 | 73 | { |
74 | 74 | $select = $this->getSql()->select() |
75 | - ->join('articles', 'article_posts.article_uuid = articles.article_uuid', ['article_id', 'slug']); |
|
75 | + ->join('articles', 'article_posts.article_uuid = articles.article_uuid', [ 'article_id', 'slug' ]); |
|
76 | 76 | |
77 | 77 | return $this->selectWith($select); |
78 | 78 | } |
@@ -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' => 'name', |
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' => 'slug', |
30 | 30 | 'required' => true, |
31 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
31 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
32 | 32 | 'validators' => [ |
33 | - ['name' => 'NotEmpty'], |
|
34 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
33 | + [ 'name' => 'NotEmpty' ], |
|
34 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
35 | 35 | ], |
36 | 36 | ]); |
37 | 37 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Category\Service; |
5 | 5 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getCategoryBySlug($urlSlug) |
71 | 71 | { |
72 | - return $this->categoryMapper->select(['slug' => $urlSlug])->current(); |
|
72 | + return $this->categoryMapper->select([ 'slug' => $urlSlug ])->current(); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | { |
83 | 83 | $filter = $this->categoryFilter->getInputFilter()->setData($data); |
84 | 84 | |
85 | - if(!$filter->isValid()) { |
|
85 | + if (!$filter->isValid()) { |
|
86 | 86 | throw new FilterException($filter->getMessages()); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $data = $filter->getValues(); |
90 | - $data['category_id'] = Uuid::uuid1()->toString(); |
|
91 | - $data['category_uuid'] = (new MysqlUuid($data['category_id']))->toFormat(new Binary); |
|
90 | + $data[ 'category_id' ] = Uuid::uuid1()->toString(); |
|
91 | + $data[ 'category_uuid' ] = (new MysqlUuid($data[ 'category_id' ]))->toFormat(new Binary); |
|
92 | 92 | |
93 | 93 | $this->categoryMapper->insert($data); |
94 | 94 | } |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function updateCategory($data, $categoryId) |
105 | 105 | { |
106 | - if(!$this->getCategory($categoryId)) { |
|
106 | + if (!$this->getCategory($categoryId)) { |
|
107 | 107 | throw new \Exception('CategoryId dos not exist.'); |
108 | 108 | } |
109 | 109 | |
110 | 110 | $filter = $this->categoryFilter->getInputFilter()->setData($data); |
111 | 111 | |
112 | - if(!$filter->isValid()) { |
|
112 | + if (!$filter->isValid()) { |
|
113 | 113 | throw new FilterException($filter->getMessages()); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $data = $filter->getValues(); |
117 | - $this->categoryMapper->update($data, ['category_id' => $categoryId]); |
|
117 | + $this->categoryMapper->update($data, [ 'category_id' => $categoryId ]); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function delete($categoryId) |
127 | 127 | { |
128 | - return (bool)$this->categoryMapper->delete(['category_id' => $categoryId]); |
|
128 | + return (bool) $this->categoryMapper->delete([ 'category_id' => $categoryId ]); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |