@@ -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 | /** |
@@ -74,13 +74,13 @@ discard block |
||
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); |
@@ -99,20 +99,20 @@ discard block |
||
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 | } else { |
108 | 108 | $this->upload->deleteFile($page->getMainImg()); |
109 | 109 | } |
110 | 110 | |
111 | - if ($data['is_homepage']) { |
|
112 | - $this->pageMapper->update(['is_homepage' => false]); |
|
111 | + if ($data[ 'is_homepage' ]) { |
|
112 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
113 | 113 | } |
114 | 114 | |
115 | - return $this->pageMapper->update($data, ['page_id' => $pageId]); |
|
115 | + return $this->pageMapper->update($data, [ 'page_id' => $pageId ]); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function delete($pageId) |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $this->upload->deleteFile($page->getMainImg()); |
125 | 125 | |
126 | - return (bool)$this->pageMapper->delete(['page_id' => $pageId]); |
|
126 | + return (bool) $this->pageMapper->delete([ 'page_id' => $pageId ]); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | public function getForSelect() |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Menu\Mapper; |
4 | 4 | |
5 | 5 | use Zend\Db\Adapter\Adapter; |
@@ -15,28 +15,28 @@ 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 | 21 | ->join( |
22 | 22 | 'category', |
23 | 23 | 'menu.category_uuid = category.category_uuid', |
24 | - ['category_name' => 'name', 'category_slug' => 'slug'], |
|
24 | + [ 'category_name' => 'name', 'category_slug' => 'slug' ], |
|
25 | 25 | 'left' |
26 | - )->join('page', 'page.page_uuid = menu.page_uuid', ['page_id', 'page_slug' => 'slug'], 'left') |
|
27 | - ->order(['order_no' => 'asc']); |
|
26 | + )->join('page', 'page.page_uuid = menu.page_uuid', [ 'page_id', 'page_slug' => 'slug' ], 'left') |
|
27 | + ->order([ 'order_no' => 'asc' ]); |
|
28 | 28 | |
29 | 29 | if ($isActive !== null) { |
30 | - $select->where(['menu.is_active' => $isActive]); |
|
30 | + $select->where([ 'menu.is_active' => $isActive ]); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | if ($filter) { |
34 | - if (isset($filter['is_in_header'])) { |
|
35 | - $select->where(['is_in_header' => $filter['is_in_header']]); |
|
36 | - } elseif (isset($filter['is_in_footer'])) { |
|
37 | - $select->where(['is_in_footer' => $filter['is_in_footer']]); |
|
38 | - } elseif (isset($filter['is_in_side'])) { |
|
39 | - $select->where(['is_in_side' => $filter['is_in_side']]); |
|
34 | + if (isset($filter[ 'is_in_header' ])) { |
|
35 | + $select->where([ 'is_in_header' => $filter[ 'is_in_header' ] ]); |
|
36 | + } elseif (isset($filter[ 'is_in_footer' ])) { |
|
37 | + $select->where([ 'is_in_footer' => $filter[ 'is_in_footer' ] ]); |
|
38 | + } elseif (isset($filter[ 'is_in_side' ])) { |
|
39 | + $select->where([ 'is_in_side' => $filter[ 'is_in_side' ] ]); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function updateMenuItem($data, $id) |
54 | 54 | { |
55 | - $this->update($data, ['menu_id' => $id]); |
|
55 | + $this->update($data, [ 'menu_id' => $id ]); |
|
56 | 56 | |
57 | 57 | return $id; |
58 | 58 | } |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | public function get($id) |
61 | 61 | { |
62 | 62 | $select = $this->getSql()->select() |
63 | - ->join('page', 'page.page_uuid = menu.page_uuid', ['page_id'], 'left') |
|
64 | - ->join('category', 'category.category_uuid = menu.category_uuid', ['category_id'], 'left') |
|
65 | - ->where(['menu_id' => $id]); |
|
63 | + ->join('page', 'page.page_uuid = menu.page_uuid', [ 'page_id' ], 'left') |
|
64 | + ->join('category', 'category.category_uuid = menu.category_uuid', [ 'category_id' ], 'left') |
|
65 | + ->where([ 'menu_id' => $id ]); |
|
66 | 66 | |
67 | 67 | return $this->selectWith($select)->current(); |
68 | 68 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | public function forSelect() |
71 | 71 | { |
72 | 72 | $select = $this->getSql()->select() |
73 | - ->columns(['menu_id', 'title', 'is_active']) |
|
74 | - ->order(['is_active' => 'desc']); |
|
73 | + ->columns([ 'menu_id', 'title', 'is_active' ]) |
|
74 | + ->order([ 'is_active' => 'desc' ]); |
|
75 | 75 | |
76 | 76 | return $this->selectWith($select); |
77 | 77 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
50 | - public function edit($errors = []) |
|
50 | + public function edit($errors = [ ]) |
|
51 | 51 | { |
52 | 52 | $id = $this->request->getAttribute('id'); |
53 | 53 | $item = $this->menuService->get($id); |
54 | 54 | |
55 | 55 | if ($this->request->getParsedBody()) { |
56 | - $item = (object)($this->request->getParsedBody() + (array)$item); |
|
56 | + $item = (object) ($this->request->getParsedBody() + (array) $item); |
|
57 | 57 | $item->menu_id = $id; |
58 | 58 | } |
59 | 59 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | public function updateOrder() |
106 | 106 | { |
107 | 107 | $data = $this->request->getParsedBody(); |
108 | - $menuOrder = isset($data['order']) ? json_decode($data['order']) : []; |
|
108 | + $menuOrder = isset($data[ 'order' ]) ? json_decode($data[ 'order' ]) : [ ]; |
|
109 | 109 | $status = $this->menuService->updateMenuOrder($menuOrder); |
110 | 110 | |
111 | - return new JsonResponse(['status' => $status]); |
|
111 | + return new JsonResponse([ 'status' => $status ]); |
|
112 | 112 | } |
113 | 113 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Menu\View\Helper; |
4 | 4 | |
5 | 5 | use Zend\View\Helper\AbstractHelper; |
@@ -31,12 +31,12 @@ discard block |
||
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']; |
|
36 | - } elseif ($menuItem['page_slug']) { |
|
37 | - return $this->url->__invoke('page', ['url_slug' => $menuItem['page_slug']]); |
|
38 | - } elseif ($menuItem['category_slug']) { |
|
39 | - return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
|
34 | + if ($menuItem[ 'href' ]) { |
|
35 | + return strpos($menuItem[ 'href' ], 'http') === 0 ? $menuItem[ 'href' ] : '/' . $menuItem[ 'href' ]; |
|
36 | + } elseif ($menuItem[ 'page_slug' ]) { |
|
37 | + return $this->url->__invoke('page', [ 'url_slug' => $menuItem[ 'page_slug' ] ]); |
|
38 | + } elseif ($menuItem[ 'category_slug' ]) { |
|
39 | + return $this->url->__invoke('category', [ 'category' => $menuItem[ 'category_slug' ] ]); |
|
40 | 40 | } else { |
41 | 41 | return '#'; |
42 | 42 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Menu\View\Helper; |
4 | 4 | |
5 | 5 | use Menu\Service\MenuService; |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Menu\View\Helper; |
4 | 4 | |
5 | 5 | use Interop\Container\ContainerInterface; |
@@ -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 | 34 | while (count($flatArray) > 0) { |
35 | 35 | for ($i = count($flatArray) - 1; $i >= 0; $i--) { |
36 | - if (!isset($flatArray[$i]['children'])) { |
|
37 | - $flatArray[$i]['children'] = []; |
|
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 | - } elseif ($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 | + } elseif ($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 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->pageService = $pageService; |
70 | 70 | } |
71 | 71 | |
72 | - public function getNestedAll($isActive = null, $filter = []) |
|
72 | + public function getNestedAll($isActive = null, $filter = [ ]) |
|
73 | 73 | { |
74 | 74 | $items = $this->menuMapper->selectAll($isActive, $filter)->toArray(); |
75 | 75 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | { |
86 | 86 | $data = $this->filterMenuItem($data); |
87 | 87 | |
88 | - $data['menu_id'] = Uuid::uuid1()->toString(); |
|
89 | - $data['menu_uuid'] = (new MysqlUuid($data['menu_id']))->toFormat(new Binary); |
|
88 | + $data[ 'menu_id' ] = Uuid::uuid1()->toString(); |
|
89 | + $data[ 'menu_uuid' ] = (new MysqlUuid($data[ 'menu_id' ]))->toFormat(new Binary); |
|
90 | 90 | |
91 | 91 | return $this->menuMapper->insertMenuItem($data); |
92 | 92 | } |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | |
101 | 101 | public function delete($id) |
102 | 102 | { |
103 | - $children = $this->menuMapper->select(['parent_id' => $id]); |
|
103 | + $children = $this->menuMapper->select([ 'parent_id' => $id ]); |
|
104 | 104 | |
105 | 105 | if ($children->count()) { |
106 | 106 | throw new \Exception('This Menu Item has child items', 400); |
107 | 107 | } |
108 | 108 | |
109 | - return $this->menuMapper->delete(['menu_id' => $id]); |
|
109 | + return $this->menuMapper->delete([ 'menu_id' => $id ]); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | public function getForSelect() |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | { |
139 | 139 | foreach ($children as $v) { |
140 | 140 | if (isset($v->children)) { |
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 | $this->updateLevel($v->children, $orderNo, $v->id); |
143 | 143 | } else { |
144 | - $this->menuMapper->update(['order_no' => $orderNo++, 'parent_id' => $parentId], ['menu_id' => $v->id]); |
|
144 | + $this->menuMapper->update([ 'order_no' => $orderNo++, 'parent_id' => $parentId ], [ 'menu_id' => $v->id ]); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -154,27 +154,27 @@ discard block |
||
154 | 154 | throw new FilterException($filter->getMessages()); |
155 | 155 | } |
156 | 156 | |
157 | - if (count(array_filter([$data['page_id'], $data['category_id'], $data['href']])) > 1) { |
|
157 | + if (count(array_filter([ $data[ 'page_id' ], $data[ 'category_id' ], $data[ 'href' ] ])) > 1) { |
|
158 | 158 | throw new \Exception('You need to set only one link. Post, Category or Href.'); |
159 | 159 | } |
160 | 160 | |
161 | 161 | $data = $filter->getValues(); |
162 | 162 | |
163 | - if ($data['page_id']) { |
|
164 | - $page = $this->pageService->getPage($data['page_id']); |
|
165 | - $data['page_uuid'] = $page->getPageUuid(); |
|
166 | - $data['category_uuid'] = null; |
|
167 | - } elseif ($data['category_id']) { |
|
163 | + if ($data[ 'page_id' ]) { |
|
164 | + $page = $this->pageService->getPage($data[ 'page_id' ]); |
|
165 | + $data[ 'page_uuid' ] = $page->getPageUuid(); |
|
166 | + $data[ 'category_uuid' ] = null; |
|
167 | + } elseif ($data[ 'category_id' ]) { |
|
168 | 168 | $category |
169 | - = $this->categoryService->getCategory($data['category_id']); |
|
170 | - $data['category_uuid'] = $category->category_uuid; |
|
171 | - $data['page_uuid'] = null; |
|
169 | + = $this->categoryService->getCategory($data[ 'category_id' ]); |
|
170 | + $data[ 'category_uuid' ] = $category->category_uuid; |
|
171 | + $data[ 'page_uuid' ] = null; |
|
172 | 172 | } else { |
173 | - $data['page_uuid'] = null; |
|
174 | - $data['category_uuid'] = null; |
|
173 | + $data[ 'page_uuid' ] = null; |
|
174 | + $data[ 'category_uuid' ] = null; |
|
175 | 175 | } |
176 | 176 | |
177 | - unset($data['page_id'], $data['category_id']); |
|
177 | + unset($data[ 'page_id' ], $data[ 'category_id' ]); |
|
178 | 178 | |
179 | 179 | return $data; |
180 | 180 | } |
@@ -27,10 +27,10 @@ discard block |
||
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,11 +47,11 @@ 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 | 52 | [ |
53 | 53 | 'name' => RecordExists::class, |
54 | - 'options' => ['table' => 'page', 'field' => 'page_id', 'adapter' => $this->db] |
|
54 | + 'options' => [ 'table' => 'page', 'field' => 'page_id', 'adapter' => $this->db ] |
|
55 | 55 | ] |
56 | 56 | ] |
57 | 57 | ] |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | [ |
62 | 62 | 'name' => 'category_id', |
63 | 63 | 'required' => false, |
64 | - 'filters' => [['name' => 'Null']], |
|
64 | + 'filters' => [ [ 'name' => 'Null' ] ], |
|
65 | 65 | 'validators' => [ |
66 | 66 | [ |
67 | 67 | 'name' => RecordExists::class, |
68 | - 'options' => ['table' => 'category', 'field' => 'category_id', 'adapter' => $this->db] |
|
68 | + 'options' => [ 'table' => 'category', 'field' => 'category_id', 'adapter' => $this->db ] |
|
69 | 69 | ] |
70 | 70 | ] |
71 | 71 | ] |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | [ |
76 | 76 | 'name' => 'is_active', |
77 | 77 | 'required' => false, |
78 | - 'filters' => [['name' => 'Boolean']] |
|
78 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
79 | 79 | ] |
80 | 80 | ); |
81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | [ |
84 | 84 | 'name' => 'is_in_header', |
85 | 85 | 'required' => false, |
86 | - 'filters' => [['name' => 'Boolean']] |
|
86 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
87 | 87 | ] |
88 | 88 | ); |
89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | [ |
92 | 92 | 'name' => 'is_in_footer', |
93 | 93 | 'required' => false, |
94 | - 'filters' => [['name' => 'Boolean']] |
|
94 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
95 | 95 | ] |
96 | 96 | ); |
97 | 97 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | [ |
100 | 100 | 'name' => 'is_in_side', |
101 | 101 | 'required' => false, |
102 | - 'filters' => [['name' => 'Boolean']] |
|
102 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
103 | 103 | ] |
104 | 104 | ); |
105 | 105 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Menu\Factory\Controller; |
4 | 4 | |
5 | 5 | use Menu\Controller\IndexController; |