@@ -10,7 +10,7 @@ |
||
10 | 10 | ->disableOriginalConstructor() |
11 | 11 | ->getMockForAbstractClass(); |
12 | 12 | $container = $this->getMockBuilder(\Interop\Container\ContainerInterface::class) |
13 | - ->setMethods(['get']) |
|
13 | + ->setMethods([ 'get' ]) |
|
14 | 14 | ->getMockForAbstractClass(); |
15 | 15 | $container->expects(static::at(0)) |
16 | 16 | ->method('get') |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | ->disableOriginalConstructor() |
14 | 14 | ->getMockForAbstractClass(); |
15 | 15 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
16 | - ->setMethods(['getPaginationSelect', 'getAdapter']) |
|
16 | + ->setMethods([ 'getPaginationSelect', 'getAdapter' ]) |
|
17 | 17 | ->disableOriginalConstructor() |
18 | 18 | ->getMockForAbstractClass(); |
19 | 19 | $pageMapper->expects(static::once()) |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
28 | 28 | ->getMockForAbstractClass(); |
29 | 29 | $container = $this->getMockBuilder(\Interop\Container\ContainerInterface::class) |
30 | - ->setMethods(['get']) |
|
30 | + ->setMethods([ 'get' ]) |
|
31 | 31 | ->getMockForAbstractClass(); |
32 | 32 | $container->expects(static::at(0)) |
33 | 33 | ->method('get') |
34 | - ->will(static::returnValue(['upload' => ['public_path' => 'test', 'non_public_path' => 'test']])); |
|
34 | + ->will(static::returnValue([ 'upload' => [ 'public_path' => 'test', 'non_public_path' => 'test' ] ])); |
|
35 | 35 | $container->expects(static::at(1)) |
36 | 36 | ->method('get') |
37 | 37 | ->will(static::returnValue($pageMapper)); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | ->disableOriginalConstructor() |
30 | 30 | ->getMock(); |
31 | 31 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
32 | - ->setMethods(['select', 'current']) |
|
32 | + ->setMethods([ 'select', 'current' ]) |
|
33 | 33 | ->disableOriginalConstructor() |
34 | 34 | ->getMock(); |
35 | 35 | $pageMapper->expects(static::once()) |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ->disableOriginalConstructor() |
56 | 56 | ->getMock(); |
57 | 57 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
58 | - ->setMethods(['getActivePage', 'current']) |
|
58 | + ->setMethods([ 'getActivePage', 'current' ]) |
|
59 | 59 | ->disableOriginalConstructor() |
60 | 60 | ->getMock(); |
61 | 61 | $pageMapper->expects(static::once()) |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ->disableOriginalConstructor() |
82 | 82 | ->getMock(); |
83 | 83 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
84 | - ->setMethods(['select', 'current']) |
|
84 | + ->setMethods([ 'select', 'current' ]) |
|
85 | 85 | ->disableOriginalConstructor() |
86 | 86 | ->getMock(); |
87 | 87 | $pageMapper->expects(static::once()) |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'is_homepage' => 1 |
108 | 108 | ]; |
109 | 109 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
110 | - ->setMethods(['getInputFilter', 'setData', 'isValid', 'getValues']) |
|
110 | + ->setMethods([ 'getInputFilter', 'setData', 'isValid', 'getValues' ]) |
|
111 | 111 | ->disableOriginalConstructor() |
112 | 112 | ->getMock(); |
113 | 113 | $pageFilter->expects(static::once()) |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ->method('setData') |
124 | 124 | ->willReturnSelf(); |
125 | 125 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
126 | - ->setMethods(['update', 'insert']) |
|
126 | + ->setMethods([ 'update', 'insert' ]) |
|
127 | 127 | ->disableOriginalConstructor() |
128 | 128 | ->getMock(); |
129 | 129 | $pageMapper->expects(static::once()) |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ]; |
152 | 152 | |
153 | 153 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
154 | - ->setMethods(['getInputFilter', 'setData', 'isValid', 'getMessages']) |
|
154 | + ->setMethods([ 'getInputFilter', 'setData', 'isValid', 'getMessages' ]) |
|
155 | 155 | ->disableOriginalConstructor() |
156 | 156 | ->getMock(); |
157 | 157 | $pageFilter->expects(static::once()) |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | ->willReturn(false); |
163 | 163 | $pageFilter->expects(static::once()) |
164 | 164 | ->method('getMessages') |
165 | - ->willReturn(['test error']); |
|
165 | + ->willReturn([ 'test error' ]); |
|
166 | 166 | $pageFilter->expects(static::once()) |
167 | 167 | ->method('setData') |
168 | 168 | ->willReturnSelf(); |
169 | 169 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
170 | - ->setMethods(['update', 'insert']) |
|
170 | + ->setMethods([ 'update', 'insert' ]) |
|
171 | 171 | ->disableOriginalConstructor() |
172 | 172 | ->getMock(); |
173 | 173 | $paginator = $this->getMockBuilder(\Zend\Paginator\Paginator::class) |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | 'is_homepage' => 1 |
192 | 192 | ]; |
193 | 193 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
194 | - ->setMethods(['select']) |
|
194 | + ->setMethods([ 'select' ]) |
|
195 | 195 | ->disableOriginalConstructor() |
196 | 196 | ->getMock(); |
197 | 197 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
198 | - ->setMethods(['select', 'current']) |
|
198 | + ->setMethods([ 'select', 'current' ]) |
|
199 | 199 | ->disableOriginalConstructor() |
200 | 200 | ->getMock(); |
201 | 201 | $pageMapper->expects(static::once()) |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'is_homepage' => 1 |
226 | 226 | ]; |
227 | 227 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
228 | - ->setMethods(['getInputFilter', 'setData', 'isValid', 'getMessages']) |
|
228 | + ->setMethods([ 'getInputFilter', 'setData', 'isValid', 'getMessages' ]) |
|
229 | 229 | ->disableOriginalConstructor() |
230 | 230 | ->getMock(); |
231 | 231 | $pageFilter->expects(static::once()) |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | ->willReturn(false); |
240 | 240 | $pageFilter->expects(static::once()) |
241 | 241 | ->method('getMessages') |
242 | - ->willReturn(['test error']); |
|
242 | + ->willReturn([ 'test error' ]); |
|
243 | 243 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
244 | - ->setMethods(['select', 'current']) |
|
244 | + ->setMethods([ 'select', 'current' ]) |
|
245 | 245 | ->disableOriginalConstructor() |
246 | 246 | ->getMock(); |
247 | 247 | $pageMapper->expects(static::once()) |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | 'is_homepage' => 1 |
268 | 268 | ]; |
269 | 269 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
270 | - ->setMethods(['getInputFilter', 'setData', 'isValid', 'getValues', 'select']) |
|
270 | + ->setMethods([ 'getInputFilter', 'setData', 'isValid', 'getValues', 'select' ]) |
|
271 | 271 | ->disableOriginalConstructor() |
272 | 272 | ->getMock(); |
273 | 273 | $pageFilter->expects(static::once()) |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | ->method('setData') |
284 | 284 | ->willReturnSelf(); |
285 | 285 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
286 | - ->setMethods(['update', 'select', 'current']) |
|
286 | + ->setMethods([ 'update', 'select', 'current' ]) |
|
287 | 287 | ->disableOriginalConstructor() |
288 | 288 | ->getMock(); |
289 | 289 | $pageMapper->expects(static::exactly(2)) |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | 'main_img' => 'test_path' |
314 | 314 | ]; |
315 | 315 | $pageFilter = $this->getMockBuilder(\Page\Filter\PageFilter::class) |
316 | - ->setMethods(['getInputFilter', 'setData', 'isValid', 'getValues', 'select']) |
|
316 | + ->setMethods([ 'getInputFilter', 'setData', 'isValid', 'getValues', 'select' ]) |
|
317 | 317 | ->disableOriginalConstructor() |
318 | 318 | ->getMock(); |
319 | 319 | $pageFilter->expects(static::once()) |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | ->method('setData') |
330 | 330 | ->willReturnSelf(); |
331 | 331 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
332 | - ->setMethods(['update', 'select', 'current']) |
|
332 | + ->setMethods([ 'update', 'select', 'current' ]) |
|
333 | 333 | ->disableOriginalConstructor() |
334 | 334 | ->getMock(); |
335 | 335 | $pageMapper->expects(static::exactly(2)) |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | ->disableOriginalConstructor() |
359 | 359 | ->getMock(); |
360 | 360 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
361 | - ->setMethods(['select', 'current', 'delete']) |
|
361 | + ->setMethods([ 'select', 'current', 'delete' ]) |
|
362 | 362 | ->disableOriginalConstructor() |
363 | 363 | ->getMock(); |
364 | 364 | $pageMapper->expects(static::once()) |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | ->disableOriginalConstructor() |
392 | 392 | ->getMock(); |
393 | 393 | $pageMapper = $this->getMockBuilder(\Page\Mapper\PageMapper::class) |
394 | - ->setMethods(['select', 'current']) |
|
394 | + ->setMethods([ 'select', 'current' ]) |
|
395 | 395 | ->disableOriginalConstructor() |
396 | 396 | ->getMock(); |
397 | 397 | $pageMapper->expects(static::once()) |
@@ -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 |
@@ -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 | } |
@@ -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 '#'; |
@@ -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 |