@@ -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 | } |
@@ -121,8 +121,7 @@ |
||
121 | 121 | $orderNo = 1; |
122 | 122 | $this->updateLevel(null, $menuOrder, $orderNo); |
123 | 123 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->commit(); |
124 | - } |
|
125 | - catch(\Exception $e) { |
|
124 | + } catch(\Exception $e) { |
|
126 | 125 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->rollback(); |
127 | 126 | |
128 | 127 | throw $e; |
@@ -33,16 +33,16 @@ |
||
33 | 33 | */ |
34 | 34 | public function __invoke($menuItem) |
35 | 35 | { |
36 | - if($menuItem['href']) { |
|
37 | - return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
|
36 | + if ($menuItem[ 'href' ]) { |
|
37 | + return strpos($menuItem[ 'href' ], 'http') === 0 ? $menuItem[ 'href' ] : '/' . $menuItem[ 'href' ]; |
|
38 | 38 | } |
39 | - elseif($menuItem['article_slug']) { |
|
40 | - $params = ['segment_1' => $menuItem['category_slug'], 'segment_2' => $menuItem['article_slug']]; |
|
39 | + elseif ($menuItem[ 'article_slug' ]) { |
|
40 | + $params = [ 'segment_1' => $menuItem[ 'category_slug' ], 'segment_2' => $menuItem[ 'article_slug' ] ]; |
|
41 | 41 | |
42 | 42 | return $this->url->__invoke('post', $params); |
43 | 43 | } |
44 | - elseif($menuItem['category_slug']) { |
|
45 | - return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
|
44 | + elseif ($menuItem[ 'category_slug' ]) { |
|
45 | + return $this->url->__invoke('category', [ 'category' => $menuItem[ 'category_slug' ] ]); |
|
46 | 46 | } |
47 | 47 | else { |
48 | 48 | return '#'; |
@@ -35,16 +35,13 @@ |
||
35 | 35 | { |
36 | 36 | if($menuItem['href']) { |
37 | 37 | return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
38 | - } |
|
39 | - elseif($menuItem['article_slug']) { |
|
38 | + } elseif($menuItem['article_slug']) { |
|
40 | 39 | $params = ['segment_1' => $menuItem['category_slug'], 'segment_2' => $menuItem['article_slug']]; |
41 | 40 | |
42 | 41 | return $this->url->__invoke('post', $params); |
43 | - } |
|
44 | - elseif($menuItem['category_slug']) { |
|
42 | + } elseif($menuItem['category_slug']) { |
|
45 | 43 | return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
46 | - } |
|
47 | - else { |
|
44 | + } else { |
|
48 | 45 | return '#'; |
49 | 46 | } |
50 | 47 | } |
@@ -11,14 +11,14 @@ |
||
11 | 11 | /** |
12 | 12 | * |
13 | 13 | * |
14 | - * @var UrlHelper |
|
14 | + * @var UrlHelper |
|
15 | 15 | */ |
16 | 16 | private $url; |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * |
20 | 20 | * |
21 | - * @var PostService |
|
21 | + * @var PostService |
|
22 | 22 | */ |
23 | 23 | private $postService; |
24 | 24 |
@@ -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 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | 'partial/menu-level' => __DIR__ . '/../templates/partial/menu-level.phtml', |
13 | 13 | ], |
14 | 14 | 'paths' => [ |
15 | - 'menu' => [__DIR__ . '/../templates/menu'], |
|
15 | + 'menu' => [ __DIR__ . '/../templates/menu' ], |
|
16 | 16 | ], |
17 | 17 | ], |
18 | 18 | |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | 'name' => 'admin.menu', |
34 | 34 | 'path' => '/admin/menu', |
35 | 35 | 'middleware' => Controller\IndexController::class, |
36 | - 'allowed_methods' => ['GET'], |
|
36 | + 'allowed_methods' => [ 'GET' ], |
|
37 | 37 | ], |
38 | 38 | [ |
39 | 39 | 'name' => 'admin.menu.action', |
40 | 40 | 'path' => '/admin/menu/:action/:id', |
41 | 41 | 'middleware' => Controller\IndexController::class, |
42 | - 'allowed_methods' => ['GET', 'POST'], |
|
42 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
43 | 43 | ], |
44 | 44 | ], |
45 | 45 |
@@ -75,17 +75,14 @@ discard block |
||
75 | 75 | |
76 | 76 | if($pageId) { |
77 | 77 | $this->pageService->updatePage($data, $pageId); |
78 | - } |
|
79 | - else { |
|
78 | + } else { |
|
80 | 79 | $this->pageService->createPage($data); |
81 | 80 | } |
82 | 81 | |
83 | 82 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.pages')); |
84 | - } |
|
85 | - catch(FilterException $fe) { |
|
83 | + } catch(FilterException $fe) { |
|
86 | 84 | return $this->edit($fe->getArrayMessages()); |
87 | - } |
|
88 | - catch(\Exception $e) { |
|
85 | + } catch(\Exception $e) { |
|
89 | 86 | throw $e; |
90 | 87 | } |
91 | 88 | } |
@@ -97,8 +94,7 @@ discard block |
||
97 | 94 | $this->pageService->delete($pageId); |
98 | 95 | |
99 | 96 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.pages')); |
100 | - } |
|
101 | - catch(\Exception $e) { |
|
97 | + } catch(\Exception $e) { |
|
102 | 98 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.pages')); |
103 | 99 | } |
104 | 100 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | public function index(): HtmlResponse |
56 | 56 | { |
57 | 57 | $params = $this->request->getQueryParams(); |
58 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
59 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
58 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
59 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
60 | 60 | $pagination = $this->pageService->getPagination($page, $limit); |
61 | 61 | |
62 | 62 | return new HtmlResponse( |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
72 | - public function edit($errors = []): HtmlResponse |
|
72 | + public function edit($errors = [ ]): HtmlResponse |
|
73 | 73 | { |
74 | 74 | $id = $this->request->getAttribute('id'); |
75 | 75 | $page = $this->pageService->getPage($id); |
76 | 76 | |
77 | - if($this->request->getParsedBody()) { |
|
77 | + if ($this->request->getParsedBody()) { |
|
78 | 78 | $page = new \Page\Entity\Page(); |
79 | - $page->exchangeArray($this->request->getParsedBody() + (array)$page); |
|
79 | + $page->exchangeArray($this->request->getParsedBody() + (array) $page); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return new HtmlResponse( |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | try { |
96 | 96 | $pageId = $this->request->getAttribute('id'); |
97 | 97 | $data = $this->request->getParsedBody(); |
98 | - $data += (new Request())->getFiles()->toArray(); |
|
98 | + $data += (new Request())->getFiles()->toArray(); |
|
99 | 99 | |
100 | - if($pageId) { |
|
100 | + if ($pageId) { |
|
101 | 101 | $this->pageService->updatePage($data, $pageId); |
102 | 102 | } |
103 | 103 | else { |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | |
107 | 107 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.pages')); |
108 | 108 | } |
109 | - catch(FilterException $fe) { |
|
109 | + catch (FilterException $fe) { |
|
110 | 110 | return $this->edit($fe->getArrayMessages()); |
111 | 111 | } |
112 | - catch(\Exception $e) { |
|
112 | + catch (\Exception $e) { |
|
113 | 113 | throw $e; |
114 | 114 | } |
115 | 115 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.pages')); |
124 | 124 | } |
125 | - catch(\Exception $e) { |
|
125 | + catch (\Exception $e) { |
|
126 | 126 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.pages')); |
127 | 127 | } |
128 | 128 | } |
@@ -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 | ]; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getDescription($limit = null) |
112 | 112 | { |
113 | - if(!$limit) { |
|
113 | + if (!$limit) { |
|
114 | 114 | return $this->description; |
115 | 115 | } |
116 | 116 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function getCreatedAt($format = null) |
167 | 167 | { |
168 | - if(!$format) { |
|
168 | + if (!$format) { |
|
169 | 169 | return $this->created_at; |
170 | 170 | } |
171 | 171 | |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param array $data |
185 | 185 | */ |
186 | - public function exchangeArray($data = []) |
|
186 | + public function exchangeArray($data = [ ]) |
|
187 | 187 | { |
188 | - foreach(array_keys(get_object_vars($this)) as $property) { |
|
189 | - $this->{$property} = isset($data[$property]) ? $data[$property] : null; |
|
188 | + foreach (array_keys(get_object_vars($this)) as $property) { |
|
189 | + $this->{$property} = isset($data[ $property ]) ? $data[ $property ] : null; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -194,18 +194,18 @@ discard block |
||
194 | 194 | public function getArrayCopy() |
195 | 195 | { |
196 | 196 | return [ |
197 | - 'page_uuid' => (binary)$this->page_uuid, |
|
198 | - 'page_id' => (string)$this->page_id, |
|
199 | - 'title' => (string)$this->title, |
|
200 | - 'body' => (string)$this->body, |
|
201 | - 'description' => (string)$this->description, |
|
202 | - 'main_img' => (string)$this->main_img, |
|
203 | - 'has_layout' => (boolean)$this->has_layout, |
|
204 | - 'is_homepage' => (boolean)$this->is_homepage, |
|
205 | - 'is_active' => (boolean)$this->is_active, |
|
206 | - 'is_wysiwyg_editor' => (boolean)$this->is_wysiwyg_editor, |
|
207 | - 'created_at' => (string)$this->created_at, |
|
208 | - 'slug' => (string)$this->slug |
|
197 | + 'page_uuid' => (binary) $this->page_uuid, |
|
198 | + 'page_id' => (string) $this->page_id, |
|
199 | + 'title' => (string) $this->title, |
|
200 | + 'body' => (string) $this->body, |
|
201 | + 'description' => (string) $this->description, |
|
202 | + 'main_img' => (string) $this->main_img, |
|
203 | + 'has_layout' => (boolean) $this->has_layout, |
|
204 | + 'is_homepage' => (boolean) $this->is_homepage, |
|
205 | + 'is_active' => (boolean) $this->is_active, |
|
206 | + 'is_wysiwyg_editor' => (boolean) $this->is_wysiwyg_editor, |
|
207 | + 'created_at' => (string) $this->created_at, |
|
208 | + 'slug' => (string) $this->slug |
|
209 | 209 | ]; |
210 | 210 | } |
211 | 211 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * |
38 | 38 | * |
39 | - * @return mixed |
|
39 | + * @return mixed |
|
40 | 40 | */ |
41 | 41 | public function getSlug() |
42 | 42 | { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * |
48 | 48 | * |
49 | - * @param mixed $slug |
|
49 | + * @param mixed $slug |
|
50 | 50 | */ |
51 | 51 | public function setSlug($slug) |
52 | 52 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * |
62 | 62 | * |
63 | - * @return mixed |
|
63 | + * @return mixed |
|
64 | 64 | */ |
65 | 65 | public function getIsActive() |
66 | 66 | { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * |
72 | 72 | * |
73 | - * @param mixed $is_active |
|
73 | + * @param mixed $is_active |
|
74 | 74 | */ |
75 | 75 | public function setIsActive($is_active) |
76 | 76 | { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * |
82 | 82 | * |
83 | - * @return binary |
|
83 | + * @return binary |
|
84 | 84 | */ |
85 | 85 | public function getPageUuid() |
86 | 86 | { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * |
92 | 92 | * |
93 | - * @param binary $page_uuid |
|
93 | + * @param binary $page_uuid |
|
94 | 94 | */ |
95 | 95 | public function setPageUuid($page_uuid) |
96 | 96 | { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * |
102 | 102 | * |
103 | - * @return mixed |
|
103 | + * @return mixed |
|
104 | 104 | */ |
105 | 105 | public function getPageId() |
106 | 106 | { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * |
112 | 112 | * |
113 | - * @param mixed $page_id |
|
113 | + * @param mixed $page_id |
|
114 | 114 | */ |
115 | 115 | public function setPageId($page_id) |
116 | 116 | { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * |
122 | 122 | * |
123 | - * @return mixed |
|
123 | + * @return mixed |
|
124 | 124 | */ |
125 | 125 | public function getTitle() |
126 | 126 | { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * |
132 | 132 | * |
133 | - * @param mixed $title |
|
133 | + * @param mixed $title |
|
134 | 134 | */ |
135 | 135 | public function setTitle($title) |
136 | 136 | { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * |
142 | 142 | * |
143 | - * @return mixed |
|
143 | + * @return mixed |
|
144 | 144 | */ |
145 | 145 | public function getBody() |
146 | 146 | { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * |
152 | 152 | * |
153 | - * @param mixed $body |
|
153 | + * @param mixed $body |
|
154 | 154 | */ |
155 | 155 | public function setBody($body) |
156 | 156 | { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * |
175 | 175 | * |
176 | - * @param mixed $description |
|
176 | + * @param mixed $description |
|
177 | 177 | */ |
178 | 178 | public function setDescription($description) |
179 | 179 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * |
185 | 185 | * |
186 | - * @return mixed |
|
186 | + * @return mixed |
|
187 | 187 | */ |
188 | 188 | public function getMainImg() |
189 | 189 | { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | /** |
194 | 194 | * |
195 | 195 | * |
196 | - * @param mixed $main_img |
|
196 | + * @param mixed $main_img |
|
197 | 197 | */ |
198 | 198 | public function setMainImg($main_img) |
199 | 199 | { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * |
205 | 205 | * |
206 | - * @return mixed |
|
206 | + * @return mixed |
|
207 | 207 | */ |
208 | 208 | public function getHasLayout() |
209 | 209 | { |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * |
221 | 221 | * |
222 | - * @return mixed |
|
222 | + * @return mixed |
|
223 | 223 | */ |
224 | 224 | public function getIsHomepage() |
225 | 225 | { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | /** |
230 | 230 | * |
231 | 231 | * |
232 | - * @param mixed $is_homepage |
|
232 | + * @param mixed $is_homepage |
|
233 | 233 | */ |
234 | 234 | public function setIsHomepage($is_homepage) |
235 | 235 | { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * |
254 | 254 | * |
255 | - * @param string $created_at |
|
255 | + * @param string $created_at |
|
256 | 256 | */ |
257 | 257 | public function setCreatedAt(string $created_at) |
258 | 258 | { |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * |
276 | 276 | * |
277 | - * @return Array |
|
277 | + * @return Array |
|
278 | 278 | */ |
279 | 279 | public function getArrayCopy() |
280 | 280 | { |
@@ -17,13 +17,16 @@ discard block |
||
17 | 17 | <span class="glyphicon glyphicon-chevron-left"></span> |
18 | 18 | </a> |
19 | 19 | </li> |
20 | - <?php else: ?> |
|
20 | + <?php else { |
|
21 | + : ?> |
|
21 | 22 | <li class="disabled"> |
22 | 23 | <a href="#"> |
23 | 24 | <span class="glyphicon glyphicon-chevron-left"></span> |
24 | 25 | </a> |
25 | 26 | </li> |
26 | - <?php endif; ?> |
|
27 | + <?php endif; |
|
28 | +} |
|
29 | +?> |
|
27 | 30 | |
28 | 31 | <!-- Numbered page links --> |
29 | 32 | <?php foreach($this->pagesInRange as $page): ?> |
@@ -33,9 +36,12 @@ discard block |
||
33 | 36 | <?php echo $page; ?> |
34 | 37 | </a> |
35 | 38 | </li> |
36 | - <?php else: ?> |
|
39 | + <?php else { |
|
40 | + : ?> |
|
37 | 41 | <li class="active"> |
38 | - <a href="#"><?php echo $page; ?></a> |
|
42 | + <a href="#"><?php echo $page; |
|
43 | +} |
|
44 | +?></a> |
|
39 | 45 | </li> |
40 | 46 | <?php endif; ?> |
41 | 47 | <?php endforeach; ?> |
@@ -47,13 +53,16 @@ discard block |
||
47 | 53 | <span class="glyphicon glyphicon-chevron-right"></span> |
48 | 54 | </a> |
49 | 55 | </li> |
50 | - <?php else: ?> |
|
56 | + <?php else { |
|
57 | + : ?> |
|
51 | 58 | <li class="disabled"> |
52 | 59 | <a href="#"> |
53 | 60 | <span class="glyphicon glyphicon-chevron-right"></span> |
54 | 61 | </a> |
55 | 62 | </li> |
56 | - <?php endif; ?> |
|
63 | + <?php endif; |
|
64 | +} |
|
65 | +?> |
|
57 | 66 | </ul> |
58 | 67 | </div> |
59 | 68 | <?php endif; ?> |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | </div> |
8 | 8 | </div> |
9 | 9 | <div class="col-sm-7"> |
10 | - <?php if($this->pageCount > 1) : ?> |
|
10 | + <?php if ($this->pageCount > 1) : ?> |
|
11 | 11 | <div class="pull-right"> |
12 | 12 | <ul class="pagination" style="margin:0px;"> |
13 | 13 | <!-- Previous page link --> |
14 | - <?php if(isset($this->previous)) : ?> |
|
14 | + <?php if (isset($this->previous)) : ?> |
|
15 | 15 | <li> |
16 | - <a href="<?php echo $this->url($this->route, isset($this->data) ? $this->data : []); ?>?page=<?php echo $this->previous; ?>"> |
|
16 | + <a href="<?php echo $this->url($this->route, isset($this->data) ? $this->data : [ ]); ?>?page=<?php echo $this->previous; ?>"> |
|
17 | 17 | <span class="glyphicon glyphicon-chevron-left"></span> |
18 | 18 | </a> |
19 | 19 | </li> |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | <?php endif; ?> |
27 | 27 | |
28 | 28 | <!-- Numbered page links --> |
29 | - <?php foreach($this->pagesInRange as $page): ?> |
|
30 | - <?php if($page != $this->current) : ?> |
|
29 | + <?php foreach ($this->pagesInRange as $page): ?> |
|
30 | + <?php if ($page != $this->current) : ?> |
|
31 | 31 | <li> |
32 | - <a href="<?php echo $this->url($this->route, isset($this->data) ? $this->data : []); ?>?page=<?php echo $page; ?>"> |
|
32 | + <a href="<?php echo $this->url($this->route, isset($this->data) ? $this->data : [ ]); ?>?page=<?php echo $page; ?>"> |
|
33 | 33 | <?php echo $page; ?> |
34 | 34 | </a> |
35 | 35 | </li> |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | <?php endforeach; ?> |
42 | 42 | |
43 | 43 | <!-- Next page link --> |
44 | - <?php if(isset($this->next)) : ?> |
|
44 | + <?php if (isset($this->next)) : ?> |
|
45 | 45 | <li> |
46 | - <a href="<?php echo $this->url($this->route, isset($this->data) ? $this->data : []); ?>?page=<?php echo $this->next; ?>"> |
|
46 | + <a href="<?php echo $this->url($this->route, isset($this->data) ? $this->data : [ ]); ?>?page=<?php echo $this->next; ?>"> |
|
47 | 47 | <span class="glyphicon glyphicon-chevron-right"></span> |
48 | 48 | </a> |
49 | 49 | </li> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Admin\Controller; |
5 | 5 | |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function login($error = false): \Psr\Http\Message\ResponseInterface |
62 | 62 | { |
63 | - if($this->session->getStorage()->user) { |
|
63 | + if ($this->session->getStorage()->user) { |
|
64 | 64 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
65 | 65 | } |
66 | 66 | |
67 | - return new HtmlResponse($this->template->render('admin::login', ['layout' => false, 'error' => $error])); |
|
67 | + return new HtmlResponse($this->template->render('admin::login', [ 'layout' => false, 'error' => $error ])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function loginHandle(): \Psr\Http\Message\ResponseInterface |
76 | 76 | { |
77 | - if($this->session->getStorage()->user) { |
|
77 | + if ($this->session->getStorage()->user) { |
|
78 | 78 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $data = $this->request->getParsedBody(); |
82 | - $email = isset($data['email']) ? $data['email'] : null; |
|
83 | - $password = isset($data['password']) ? $data['password'] : null; |
|
82 | + $email = isset($data[ 'email' ]) ? $data[ 'email' ] : null; |
|
83 | + $password = isset($data[ 'password' ]) ? $data[ 'password' ] : null; |
|
84 | 84 | |
85 | 85 | try { |
86 | 86 | $this->session->getStorage()->user = $this->adminUserService->loginUser($email, $password); |
87 | 87 | |
88 | 88 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
89 | 89 | } |
90 | - catch(\Exception $e) { |
|
90 | + catch (\Exception $e) { |
|
91 | 91 | return $this->login($e->getMessage()); |
92 | 92 | |
93 | 93 | //@todo set $e->getMessage() to flash messanger and print messages in next page |
@@ -86,8 +86,7 @@ |
||
86 | 86 | $this->session->getStorage()->user = $this->adminUserService->loginUser($email, $password); |
87 | 87 | |
88 | 88 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
89 | - } |
|
90 | - catch(\Exception $e) { |
|
89 | + } catch(\Exception $e) { |
|
91 | 90 | return $this->login($e->getMessage()); |
92 | 91 | |
93 | 92 | //@todo set $e->getMessage() to flash messanger and print messages in next page |