@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'page/pagination' => __DIR__ . '/../templates/partial/pagination.php', |
15 | 15 | ], |
16 | 16 | 'paths' => [ |
17 | - 'page' => [__DIR__ . '/../templates/page'], |
|
17 | + 'page' => [ __DIR__ . '/../templates/page' ], |
|
18 | 18 | ], |
19 | 19 | ], |
20 | 20 | |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | 'name' => 'admin.pages', |
33 | 33 | 'path' => '/admin/pages', |
34 | 34 | 'middleware' => Controller\PageController::class, |
35 | - 'allowed_methods' => ['GET'], |
|
35 | + 'allowed_methods' => [ 'GET' ], |
|
36 | 36 | ], |
37 | 37 | [ |
38 | 38 | 'name' => 'admin.pages.action', |
39 | 39 | 'path' => '/admin/pages/:action/:id', |
40 | 40 | 'middleware' => Controller\PageController::class, |
41 | - 'allowed_methods' => ['GET', 'POST'] |
|
41 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
42 | 42 | ] |
43 | 43 | ], |
44 | 44 |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @param array $data |
230 | 230 | */ |
231 | - public function exchangeArray($data = []) |
|
231 | + public function exchangeArray($data = [ ]) |
|
232 | 232 | { |
233 | 233 | foreach (array_keys(get_object_vars($this)) as $property) { |
234 | - $this->{$property} = isset($data[$property]) ? $data[$property] |
|
234 | + $this->{$property} = isset($data[ $property ]) ? $data[ $property ] |
|
235 | 235 | : null; |
236 | 236 | } |
237 | 237 | } |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | public function getArrayCopy() |
243 | 243 | { |
244 | 244 | return [ |
245 | - 'page_uuid' => (binary)$this->page_uuid, |
|
246 | - 'page_id' => (string)$this->page_id, |
|
247 | - 'title' => (string)$this->title, |
|
248 | - 'body' => (string)$this->body, |
|
249 | - 'description' => (string)$this->description, |
|
250 | - 'main_img' => (string)$this->main_img, |
|
251 | - 'has_layout' => (boolean)$this->has_layout, |
|
252 | - 'is_homepage' => (boolean)$this->is_homepage, |
|
253 | - 'is_active' => (boolean)$this->is_active, |
|
254 | - 'is_wysiwyg_editor' => (boolean)$this->is_wysiwyg_editor, |
|
255 | - 'created_at' => (string)$this->created_at, |
|
256 | - 'slug' => (string)$this->slug |
|
245 | + 'page_uuid' => (binary) $this->page_uuid, |
|
246 | + 'page_id' => (string) $this->page_id, |
|
247 | + 'title' => (string) $this->title, |
|
248 | + 'body' => (string) $this->body, |
|
249 | + 'description' => (string) $this->description, |
|
250 | + 'main_img' => (string) $this->main_img, |
|
251 | + 'has_layout' => (boolean) $this->has_layout, |
|
252 | + 'is_homepage' => (boolean) $this->is_homepage, |
|
253 | + 'is_active' => (boolean) $this->is_active, |
|
254 | + 'is_wysiwyg_editor' => (boolean) $this->is_wysiwyg_editor, |
|
255 | + 'created_at' => (string) $this->created_at, |
|
256 | + 'slug' => (string) $this->slug |
|
257 | 257 | ]; |
258 | 258 | } |
259 | 259 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getPage($pageId) |
42 | 42 | { |
43 | - return $this->pageMapper->select(['page_id' => $pageId])->current(); |
|
43 | + return $this->pageMapper->select([ 'page_id' => $pageId ])->current(); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getHomepage() |
59 | 59 | { |
60 | - return $this->pageMapper->select(['is_homepage' => true])->current(); |
|
60 | + return $this->pageMapper->select([ 'is_homepage' => true ])->current(); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | { |
70 | 70 | $filter = $this->pageFilter->getInputFilter()->setData($data); |
71 | 71 | |
72 | - if(!$filter->isValid()){ |
|
72 | + if (!$filter->isValid()) { |
|
73 | 73 | throw new FilterException($filter->getMessages()); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $data = $filter->getValues() |
77 | - + ['main_img' => $this->upload->uploadImage($data, 'main_img')]; |
|
78 | - $data['page_id'] = Uuid::uuid1()->toString(); |
|
79 | - $data['page_uuid'] |
|
80 | - = (new MysqlUuid($data['page_id']))->toFormat(new Binary); |
|
77 | + + [ 'main_img' => $this->upload->uploadImage($data, 'main_img') ]; |
|
78 | + $data[ 'page_id' ] = Uuid::uuid1()->toString(); |
|
79 | + $data[ 'page_uuid' ] |
|
80 | + = (new MysqlUuid($data[ 'page_id' ]))->toFormat(new Binary); |
|
81 | 81 | |
82 | - if($data['is_homepage']){ |
|
83 | - $this->pageMapper->update(['is_homepage' => false]); |
|
82 | + if ($data[ 'is_homepage' ]) { |
|
83 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this->pageMapper->insert($data); |
@@ -88,43 +88,43 @@ discard block |
||
88 | 88 | |
89 | 89 | public function updatePage($data, $pageId) |
90 | 90 | { |
91 | - if(!($page = $this->getPage($pageId))){ |
|
91 | + if (!($page = $this->getPage($pageId))) { |
|
92 | 92 | throw new \Exception('Page object not found. Page ID:' . $pageId); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $filter = $this->pageFilter->getInputFilter()->setData($data); |
96 | 96 | |
97 | - if(!$filter->isValid()){ |
|
97 | + if (!$filter->isValid()) { |
|
98 | 98 | throw new FilterException($filter->getMessages()); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $data = $filter->getValues() |
102 | - + ['main_img' => $this->upload->uploadImage($data, 'main_img')]; |
|
102 | + + [ 'main_img' => $this->upload->uploadImage($data, 'main_img') ]; |
|
103 | 103 | |
104 | 104 | // We don't want to force user to re-upload image on edit |
105 | - if(!$data['main_img']){ |
|
106 | - unset($data['main_img']); |
|
105 | + if (!$data[ 'main_img' ]) { |
|
106 | + unset($data[ 'main_img' ]); |
|
107 | 107 | } |
108 | - else{ |
|
108 | + else { |
|
109 | 109 | $this->upload->deleteFile($page->getMainImg()); |
110 | 110 | } |
111 | 111 | |
112 | - if($data['is_homepage']){ |
|
113 | - $this->pageMapper->update(['is_homepage' => false]); |
|
112 | + if ($data[ 'is_homepage' ]) { |
|
113 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
114 | 114 | } |
115 | 115 | |
116 | - return $this->pageMapper->update($data, ['page_id' => $pageId]); |
|
116 | + return $this->pageMapper->update($data, [ 'page_id' => $pageId ]); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | public function delete($pageId) |
120 | 120 | { |
121 | - if(!($page = $this->getPage($pageId))){ |
|
121 | + if (!($page = $this->getPage($pageId))) { |
|
122 | 122 | throw new \Exception('Page not found'); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $this->upload->deleteFile($page->getMainImg()); |
126 | 126 | |
127 | - return (bool)$this->pageMapper->delete(['page_id' => $pageId]); |
|
127 | + return (bool) $this->pageMapper->delete([ 'page_id' => $pageId ]); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function getForSelect() |
@@ -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('page', 'page.page_uuid = menu.page_uuid', ['page_id', 'page_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('page', 'page.page_uuid = menu.page_uuid', [ 'page_id', 'page_slug' => 'slug' ], 'left') |
|
23 | + ->order([ 'order_no' => 'asc' ]); |
|
24 | 24 | |
25 | - if($isActive !== null) { |
|
26 | - $select->where(['menu.is_active' => $isActive]); |
|
25 | + if ($isActive !== null) { |
|
26 | + $select->where([ 'menu.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('page', 'page.page_uuid = menu.page_uuid', ['page_id'], 'left') |
|
60 | - ->join('category', 'category.category_uuid = menu.category_uuid', ['category_id'], 'left') |
|
61 | - ->where(['menu_id' => $id]); |
|
59 | + ->join('page', 'page.page_uuid = menu.page_uuid', [ 'page_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 | } |
@@ -163,7 +163,7 @@ |
||
163 | 163 | $data['category_uuid'] = null; |
164 | 164 | } elseif ($data['category_id']) { |
165 | 165 | $category |
166 | - = $this->categoryService->getCategory($data['category_id']); |
|
166 | + = $this->categoryService->getCategory($data['category_id']); |
|
167 | 167 | $data['category_uuid'] = $category->category_uuid; |
168 | 168 | $data['page_uuid'] = null; |
169 | 169 | } else { |
@@ -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->pageService = $pageService; |
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,31 +147,31 @@ 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['page_id'], $data['category_id'], $data['href']])) > 1) { |
|
154 | + if (count(array_filter([ $data[ 'page_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['page_id']) { |
|
161 | - $page = $this->pageService->getPage($data['page_id']); |
|
162 | - $data['page_uuid'] = $page->getPageUuid(); |
|
163 | - $data['category_uuid'] = null; |
|
164 | - } elseif ($data['category_id']) { |
|
160 | + if ($data[ 'page_id' ]) { |
|
161 | + $page = $this->pageService->getPage($data[ 'page_id' ]); |
|
162 | + $data[ 'page_uuid' ] = $page->getPageUuid(); |
|
163 | + $data[ 'category_uuid' ] = null; |
|
164 | + } elseif ($data[ 'category_id' ]) { |
|
165 | 165 | $category |
166 | - = $this->categoryService->getCategory($data['category_id']); |
|
167 | - $data['category_uuid'] = $category->category_uuid; |
|
168 | - $data['page_uuid'] = null; |
|
166 | + = $this->categoryService->getCategory($data[ 'category_id' ]); |
|
167 | + $data[ 'category_uuid' ] = $category->category_uuid; |
|
168 | + $data[ 'page_uuid' ] = null; |
|
169 | 169 | } else { |
170 | - $data['page_uuid'] = null; |
|
171 | - $data['category_uuid'] = null; |
|
170 | + $data[ 'page_uuid' ] = null; |
|
171 | + $data[ 'category_uuid' ] = null; |
|
172 | 172 | } |
173 | 173 | |
174 | - unset($data['page_id'], $data['category_id']); |
|
174 | + unset($data[ 'page_id' ], $data[ 'category_id' ]); |
|
175 | 175 | |
176 | 176 | return $data; |
177 | 177 | } |
@@ -31,14 +31,14 @@ |
||
31 | 31 | */ |
32 | 32 | public function __invoke($menuItem) |
33 | 33 | { |
34 | - if($menuItem['href']) { |
|
35 | - return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
|
34 | + if ($menuItem[ 'href' ]) { |
|
35 | + return strpos($menuItem[ 'href' ], 'http') === 0 ? $menuItem[ 'href' ] : '/' . $menuItem[ 'href' ]; |
|
36 | 36 | } |
37 | - elseif($menuItem['page_slug']) { |
|
38 | - return $this->url->__invoke('page', ['url_slug' => $menuItem['page_slug']]); |
|
37 | + elseif ($menuItem[ 'page_slug' ]) { |
|
38 | + return $this->url->__invoke('page', [ 'url_slug' => $menuItem[ 'page_slug' ] ]); |
|
39 | 39 | } |
40 | - elseif($menuItem['category_slug']) { |
|
41 | - return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
|
40 | + elseif ($menuItem[ 'category_slug' ]) { |
|
41 | + return $this->url->__invoke('category', [ 'category' => $menuItem[ 'category_slug' ] ]); |
|
42 | 42 | } |
43 | 43 | else { |
44 | 44 | return '#'; |
@@ -33,14 +33,11 @@ |
||
33 | 33 | { |
34 | 34 | if($menuItem['href']) { |
35 | 35 | return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
36 | - } |
|
37 | - elseif($menuItem['page_slug']) { |
|
36 | + } elseif($menuItem['page_slug']) { |
|
38 | 37 | return $this->url->__invoke('page', ['url_slug' => $menuItem['page_slug']]); |
39 | - } |
|
40 | - elseif($menuItem['category_slug']) { |
|
38 | + } elseif($menuItem['category_slug']) { |
|
41 | 39 | return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
42 | - } |
|
43 | - else { |
|
40 | + } else { |
|
44 | 41 | return '#'; |
45 | 42 | } |
46 | 43 | } |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | |
21 | 21 | public function getInputFilter() |
22 | 22 | { |
23 | - if(!$this->inputFilter) { |
|
23 | + if (!$this->inputFilter) { |
|
24 | 24 | $inputFilter = new InputFilter(); |
25 | 25 | |
26 | 26 | $inputFilter->add( |
27 | 27 | [ |
28 | 28 | 'name' => 'title', |
29 | 29 | 'required' => true, |
30 | - 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], |
|
30 | + 'filters' => [ [ 'name' => 'StripTags' ], [ 'name' => 'StringTrim' ] ], |
|
31 | 31 | 'validators' => [ |
32 | - ['name' => 'NotEmpty'], |
|
33 | - ['name' => 'StringLength', 'options' => ['max' => '255']], |
|
32 | + [ 'name' => 'NotEmpty' ], |
|
33 | + [ 'name' => 'StringLength', 'options' => [ 'max' => '255' ] ], |
|
34 | 34 | ], |
35 | 35 | ] |
36 | 36 | ); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | [ |
40 | 40 | 'name' => 'href', |
41 | 41 | 'required' => false, |
42 | - 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']] |
|
42 | + 'filters' => [ [ 'name' => 'StripTags' ], [ 'name' => 'StringTrim' ] ] |
|
43 | 43 | ] |
44 | 44 | ); |
45 | 45 | |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | [ |
48 | 48 | 'name' => 'page_id', |
49 | 49 | 'required' => false, |
50 | - 'filters' => [['name' => 'Null']], |
|
50 | + 'filters' => [ [ 'name' => 'Null' ] ], |
|
51 | 51 | 'validators' => [ |
52 | - ['name' => RecordExists::class, 'options' => ['table' => 'page', 'field' => 'page_id', 'adapter' => $this->db]] |
|
52 | + [ 'name' => RecordExists::class, 'options' => [ 'table' => 'page', 'field' => 'page_id', 'adapter' => $this->db ] ] |
|
53 | 53 | ] |
54 | 54 | ] |
55 | 55 | ); |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | [ |
59 | 59 | 'name' => 'category_id', |
60 | 60 | 'required' => false, |
61 | - 'filters' => [['name' => 'Null']], |
|
61 | + 'filters' => [ [ 'name' => 'Null' ] ], |
|
62 | 62 | 'validators' => [ |
63 | - ['name' => RecordExists::class, 'options' => ['table' => 'category', 'field' => 'category_id', 'adapter' => $this->db]] |
|
63 | + [ 'name' => RecordExists::class, 'options' => [ 'table' => 'category', 'field' => 'category_id', 'adapter' => $this->db ] ] |
|
64 | 64 | ] |
65 | 65 | ] |
66 | 66 | ); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | [ |
70 | 70 | 'name' => 'is_active', |
71 | 71 | 'required' => false, |
72 | - 'filters' => [['name' => 'Boolean']] |
|
72 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
73 | 73 | ] |
74 | 74 | ); |
75 | 75 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | [ |
78 | 78 | 'name' => 'is_in_header', |
79 | 79 | 'required' => false, |
80 | - 'filters' => [['name' => 'Boolean']] |
|
80 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
81 | 81 | ] |
82 | 82 | ); |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | [ |
86 | 86 | 'name' => 'is_in_footer', |
87 | 87 | 'required' => false, |
88 | - 'filters' => [['name' => 'Boolean']] |
|
88 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
89 | 89 | ] |
90 | 90 | ); |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | [ |
94 | 94 | 'name' => 'is_in_side', |
95 | 95 | 'required' => false, |
96 | - 'filters' => [['name' => 'Boolean']] |
|
96 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
97 | 97 | ] |
98 | 98 | ); |
99 | 99 |
@@ -6,19 +6,19 @@ |
||
6 | 6 | { |
7 | 7 | public function change() |
8 | 8 | { |
9 | - $this->table('page', ['id' => false, 'primary_key' => 'page_uuid']) |
|
10 | - ->addColumn('page_uuid', 'binary', ['limit' => 16]) |
|
9 | + $this->table('page', [ 'id' => false, 'primary_key' => 'page_uuid' ]) |
|
10 | + ->addColumn('page_uuid', 'binary', [ 'limit' => 16 ]) |
|
11 | 11 | ->addColumn('page_id', 'text') |
12 | 12 | ->addColumn('title', 'text') |
13 | 13 | ->addColumn('body', 'text') |
14 | 14 | ->addColumn('description', 'text') |
15 | 15 | ->addColumn('slug', 'text') |
16 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
17 | - ->addColumn('has_layout', 'boolean', ['default' => true]) |
|
18 | - ->addColumn('is_homepage', 'boolean', ['default' => false]) |
|
19 | - ->addColumn('is_active', 'boolean', ['default' => false]) |
|
20 | - ->addColumn('is_wysiwyg_editor', 'boolean', ['default' => false]) |
|
21 | - ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP']) |
|
16 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
17 | + ->addColumn('has_layout', 'boolean', [ 'default' => true ]) |
|
18 | + ->addColumn('is_homepage', 'boolean', [ 'default' => false ]) |
|
19 | + ->addColumn('is_active', 'boolean', [ 'default' => false ]) |
|
20 | + ->addColumn('is_wysiwyg_editor', 'boolean', [ 'default' => false ]) |
|
21 | + ->addColumn('created_at', 'timestamp', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
22 | 22 | ->create(); |
23 | 23 | } |
24 | 24 | } |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | public function up() |
9 | 9 | { |
10 | - $this->table('menu', ['id' => false, 'primary_key' => 'menu_uuid']) |
|
11 | - ->addColumn('menu_uuid', 'binary', ['limit' => 16]) |
|
10 | + $this->table('menu', [ 'id' => false, 'primary_key' => 'menu_uuid' ]) |
|
11 | + ->addColumn('menu_uuid', 'binary', [ 'limit' => 16 ]) |
|
12 | 12 | ->addColumn('menu_id', 'text') |
13 | - ->addColumn('parent_id', 'text', ['null' => true]) |
|
13 | + ->addColumn('parent_id', 'text', [ 'null' => true ]) |
|
14 | 14 | ->addColumn('title', 'text') |
15 | - ->addColumn('href', 'text', ['null' => true]) |
|
16 | - ->addColumn('is_active', 'boolean', ['default' => false]) |
|
17 | - ->addColumn('is_in_header', 'boolean', ['default' => true]) |
|
18 | - ->addColumn('is_in_footer', 'boolean', ['default' => true]) |
|
19 | - ->addColumn('is_in_side', 'boolean', ['default' => true]) |
|
20 | - ->addColumn('order_no', 'integer', ['default' => 0]) |
|
21 | - ->addColumn('created_at', 'datetime', ['null' => true]) |
|
15 | + ->addColumn('href', 'text', [ 'null' => true ]) |
|
16 | + ->addColumn('is_active', 'boolean', [ 'default' => false ]) |
|
17 | + ->addColumn('is_in_header', 'boolean', [ 'default' => true ]) |
|
18 | + ->addColumn('is_in_footer', 'boolean', [ 'default' => true ]) |
|
19 | + ->addColumn('is_in_side', 'boolean', [ 'default' => true ]) |
|
20 | + ->addColumn('order_no', 'integer', [ 'default' => 0 ]) |
|
21 | + ->addColumn('created_at', 'datetime', [ 'null' => true ]) |
|
22 | 22 | //->addForeignKey('parent_id', 'menu', 'id', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) # we can not add constraints |
23 | - ->addColumn('page_uuid', 'binary', ['limit' => 16, 'null' => true]) |
|
24 | - ->addColumn('category_uuid', 'binary', ['limit' => 16, 'null' => true]) |
|
25 | - ->addForeignKey('page_uuid', 'page', 'page_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
26 | - ->addForeignKey('category_uuid', 'category', 'category_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
23 | + ->addColumn('page_uuid', 'binary', [ 'limit' => 16, 'null' => true ]) |
|
24 | + ->addColumn('category_uuid', 'binary', [ 'limit' => 16, 'null' => true ]) |
|
25 | + ->addForeignKey('page_uuid', 'page', 'page_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
26 | + ->addForeignKey('category_uuid', 'category', 'category_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
27 | 27 | ->create(); |
28 | 28 | } |
29 | 29 |