@@ -33,7 +33,7 @@ |
||
33 | 33 | */ |
34 | 34 | public function forWeb() |
35 | 35 | { |
36 | - if(!$this->categoriesWithPosts) { |
|
36 | + if (!$this->categoriesWithPosts) { |
|
37 | 37 | $this->categoriesWithPosts = $this->categoryService->getWebCategories(); |
38 | 38 | } |
39 | 39 |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | public function index() : \Psr\Http\Message\ResponseInterface |
48 | 48 | { |
49 | 49 | $params = $this->request->getQueryParams(); |
50 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
51 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
50 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
51 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
52 | 52 | |
53 | 53 | $categories = $this->categoryService->getPagination($page, $limit); |
54 | 54 | |
55 | - return new HtmlResponse($this->template->render('category::index/index', ['list' => $categories, 'layout' => 'layout/admin'])); |
|
55 | + return new HtmlResponse($this->template->render('category::index/index', [ 'list' => $categories, 'layout' => 'layout/admin' ])); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return \Psr\Http\Message\ResponseInterface |
62 | 62 | */ |
63 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
63 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
64 | 64 | { |
65 | 65 | $id = $this->request->getAttribute('id'); |
66 | 66 | $category = $this->categoryService->getCategory($id); |
67 | 67 | |
68 | - if($this->request->getParsedBody()){ |
|
69 | - $category = (object)($this->request->getParsedBody() + (array)$category); |
|
68 | + if ($this->request->getParsedBody()) { |
|
69 | + $category = (object) ($this->request->getParsedBody() + (array) $category); |
|
70 | 70 | $category->category_id = $id; |
71 | 71 | } |
72 | 72 | |
@@ -79,36 +79,36 @@ discard block |
||
79 | 79 | |
80 | 80 | public function save() |
81 | 81 | { |
82 | - try{ |
|
82 | + try { |
|
83 | 83 | $id = $this->request->getAttribute('id'); |
84 | 84 | $data = $this->request->getParsedBody(); |
85 | 85 | |
86 | - if($id){ |
|
86 | + if ($id) { |
|
87 | 87 | $this->categoryService->updateCategory($data, $id); |
88 | 88 | } |
89 | - else{ |
|
89 | + else { |
|
90 | 90 | $this->categoryService->createCategory($data); |
91 | 91 | } |
92 | 92 | |
93 | 93 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
94 | 94 | } |
95 | - catch(FilterException $fe){ |
|
95 | + catch (FilterException $fe) { |
|
96 | 96 | return $this->edit($fe->getArrayMessages()); |
97 | 97 | } |
98 | - catch(\Exception $e){ |
|
98 | + catch (\Exception $e) { |
|
99 | 99 | throw $e; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | public function delete() |
104 | 104 | { |
105 | - try{ |
|
105 | + try { |
|
106 | 106 | $id = $this->request->getAttribute('id'); |
107 | 107 | $this->categoryService->delete($id); |
108 | 108 | |
109 | 109 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
110 | 110 | } |
111 | - catch(\Exception $e){ |
|
111 | + catch (\Exception $e) { |
|
112 | 112 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
113 | 113 | } |
114 | 114 | } |
@@ -85,17 +85,14 @@ discard block |
||
85 | 85 | |
86 | 86 | if($id){ |
87 | 87 | $this->categoryService->updateCategory($data, $id); |
88 | - } |
|
89 | - else{ |
|
88 | + } else{ |
|
90 | 89 | $this->categoryService->createCategory($data); |
91 | 90 | } |
92 | 91 | |
93 | 92 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
94 | - } |
|
95 | - catch(FilterException $fe){ |
|
93 | + } catch(FilterException $fe){ |
|
96 | 94 | return $this->edit($fe->getArrayMessages()); |
97 | - } |
|
98 | - catch(\Exception $e){ |
|
95 | + } catch(\Exception $e){ |
|
99 | 96 | throw $e; |
100 | 97 | } |
101 | 98 | } |
@@ -107,8 +104,7 @@ discard block |
||
107 | 104 | $this->categoryService->delete($id); |
108 | 105 | |
109 | 106 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
110 | - } |
|
111 | - catch(\Exception $e){ |
|
107 | + } catch(\Exception $e){ |
|
112 | 108 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
113 | 109 | } |
114 | 110 | } |
@@ -12,26 +12,26 @@ |
||
12 | 12 | |
13 | 13 | public function getInputFilter() |
14 | 14 | { |
15 | - if(!$this->inputFilter) { |
|
15 | + if (!$this->inputFilter) { |
|
16 | 16 | $inputFilter = new InputFilter(); |
17 | 17 | |
18 | 18 | $inputFilter->add([ |
19 | 19 | 'name' => 'name', |
20 | 20 | 'required' => true, |
21 | - 'filters' => [['name' => 'StringTrim']], |
|
21 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
22 | 22 | 'validators' => [ |
23 | - ['name' => 'NotEmpty'], |
|
24 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
23 | + [ 'name' => 'NotEmpty' ], |
|
24 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
25 | 25 | ], |
26 | 26 | ]); |
27 | 27 | |
28 | 28 | $inputFilter->add([ |
29 | 29 | 'name' => 'slug', |
30 | 30 | 'required' => true, |
31 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
31 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
32 | 32 | 'validators' => [ |
33 | - ['name' => 'NotEmpty'], |
|
34 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
33 | + [ 'name' => 'NotEmpty' ], |
|
34 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
35 | 35 | ], |
36 | 36 | ]); |
37 | 37 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | return [ |
10 | 10 | 'templates' => [ |
11 | 11 | 'paths' => [ |
12 | - 'category' => [__DIR__ . '/../templates/category'], |
|
12 | + 'category' => [ __DIR__ . '/../templates/category' ], |
|
13 | 13 | ], |
14 | 14 | ], |
15 | 15 | |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | 'name' => 'admin.categories', |
31 | 31 | 'path' => '/admin/categories', |
32 | 32 | 'middleware' => Controller\IndexController::class, |
33 | - 'allowed_methods' => ['GET'], |
|
33 | + 'allowed_methods' => [ 'GET' ], |
|
34 | 34 | ], |
35 | 35 | [ |
36 | 36 | 'name' => 'admin.categories.action', |
37 | 37 | 'path' => '/admin/categories/:action/:id', |
38 | 38 | 'middleware' => Controller\IndexController::class, |
39 | - 'allowed_methods' => ['GET', 'POST'] |
|
39 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
40 | 40 | ], |
41 | 41 | ], |
42 | 42 |
@@ -13,8 +13,8 @@ |
||
13 | 13 | 'article/pagination' => 'templates/partial/pagination.phtml', |
14 | 14 | ], |
15 | 15 | 'paths' => [ |
16 | - 'templates' => ['templates'], |
|
17 | - 'web' => ['templates/web'], |
|
16 | + 'templates' => [ 'templates' ], |
|
17 | + 'web' => [ 'templates/web' ], |
|
18 | 18 | ], |
19 | 19 | ], |
20 | 20 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Factory\Action; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Factory\Action; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Factory\Action; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Factory\Action; |
6 | 6 |