@@ -54,7 +54,7 @@ |
||
54 | 54 | if (!$user) { |
55 | 55 | return $response->withStatus(302)->withHeader( |
56 | 56 | 'Location', |
57 | - $this->router->generateUri('auth', ['action' => 'login']) |
|
57 | + $this->router->generateUri('auth', [ 'action' => 'login' ]) |
|
58 | 58 | ); |
59 | 59 | } |
60 | 60 |
@@ -15,14 +15,14 @@ |
||
15 | 15 | |
16 | 16 | public function registerNew($email) |
17 | 17 | { |
18 | - if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
18 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
19 | 19 | throw new \Exception('Email is not valid!', 400); |
20 | 20 | } |
21 | 21 | |
22 | - $current = $this->newsletterMapper->select(['email' => $email])->current(); |
|
22 | + $current = $this->newsletterMapper->select([ 'email' => $email ])->current(); |
|
23 | 23 | |
24 | - if(!$current) { |
|
25 | - return $this->newsletterMapper->insert(['email' => $email]); |
|
24 | + if (!$current) { |
|
25 | + return $this->newsletterMapper->insert([ 'email' => $email ]); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Newsletter\Service; |
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 Newsletter\Mapper; |
6 | 6 |
@@ -20,14 +20,14 @@ |
||
20 | 20 | { |
21 | 21 | try { |
22 | 22 | $data = $request->getParsedBody(); |
23 | - $email = isset($data['email']) ? $data['email'] : null; |
|
23 | + $email = isset($data[ 'email' ]) ? $data[ 'email' ] : null; |
|
24 | 24 | |
25 | 25 | $this->newsletterService->registerNew($email); |
26 | 26 | |
27 | - return new JsonResponse(['message' => 'Uspešno ste se prijavili.']); |
|
27 | + return new JsonResponse([ 'message' => 'Uspešno ste se prijavili.' ]); |
|
28 | 28 | } |
29 | - catch(\Exception $e) { |
|
30 | - return new JsonResponse(['message' => $e->getMessage()], $e->getCode()); |
|
29 | + catch (\Exception $e) { |
|
30 | + return new JsonResponse([ 'message' => $e->getMessage() ], $e->getCode()); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
@@ -25,8 +25,7 @@ |
||
25 | 25 | $this->newsletterService->registerNew($email); |
26 | 26 | |
27 | 27 | return new JsonResponse(['message' => 'Uspešno ste se prijavili.']); |
28 | - } |
|
29 | - catch(\Exception $e) { |
|
28 | + } catch(\Exception $e) { |
|
30 | 29 | return new JsonResponse(['message' => $e->getMessage()], $e->getCode()); |
31 | 30 | } |
32 | 31 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Newsletter\Web\Action; |
6 | 6 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | return [ |
10 | 10 | 'templates' => [ |
11 | 11 | 'paths' => [ |
12 | - 'newsletter' => [__DIR__ . '/../templates/newsletter'], |
|
12 | + 'newsletter' => [ __DIR__ . '/../templates/newsletter' ], |
|
13 | 13 | ], |
14 | 14 | ], |
15 | 15 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'name' => 'newsletter-post', |
27 | 27 | 'path' => '/newsletter', |
28 | 28 | 'middleware' => Web\Action\HandlePostAction::class, |
29 | - 'allowed_methods' => ['POST'], |
|
29 | + 'allowed_methods' => [ 'POST' ], |
|
30 | 30 | ], |
31 | 31 | ], |
32 | 32 | ]; |
@@ -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 | } |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | public function index() : \Psr\Http\Message\ResponseInterface |
49 | 49 | { |
50 | 50 | $params = $this->request->getQueryParams(); |
51 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
52 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
51 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
52 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
53 | 53 | |
54 | 54 | $categories = $this->categoryService->getPagination($page, $limit); |
55 | 55 | |
56 | - return new HtmlResponse($this->template->render('category::index/index', ['list' => $categories, 'layout' => 'layout/admin'])); |
|
56 | + return new HtmlResponse($this->template->render('category::index/index', [ 'list' => $categories, 'layout' => 'layout/admin' ])); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return \Psr\Http\Message\ResponseInterface |
63 | 63 | */ |
64 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
64 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
65 | 65 | { |
66 | 66 | $id = $this->request->getAttribute('id'); |
67 | 67 | $category = $this->categoryService->getCategory($id); |
68 | 68 | |
69 | - if($this->request->getParsedBody()){ |
|
70 | - $category = (object)($this->request->getParsedBody() + (array)$category); |
|
69 | + if ($this->request->getParsedBody()) { |
|
70 | + $category = (object) ($this->request->getParsedBody() + (array) $category); |
|
71 | 71 | $category->category_id = $id; |
72 | 72 | } |
73 | 73 | |
@@ -80,37 +80,37 @@ discard block |
||
80 | 80 | |
81 | 81 | public function save() |
82 | 82 | { |
83 | - try{ |
|
83 | + try { |
|
84 | 84 | $id = $this->request->getAttribute('id'); |
85 | 85 | $data = $this->request->getParsedBody(); |
86 | 86 | $data += (new Request())->getFiles()->toArray(); |
87 | 87 | |
88 | - if($id){ |
|
88 | + if ($id) { |
|
89 | 89 | $this->categoryService->updateCategory($data, $id); |
90 | 90 | } |
91 | - else{ |
|
91 | + else { |
|
92 | 92 | $this->categoryService->createCategory($data); |
93 | 93 | } |
94 | 94 | |
95 | 95 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
96 | 96 | } |
97 | - catch(FilterException $fe){ |
|
97 | + catch (FilterException $fe) { |
|
98 | 98 | return $this->edit($fe->getArrayMessages()); |
99 | 99 | } |
100 | - catch(\Exception $e){ |
|
100 | + catch (\Exception $e) { |
|
101 | 101 | throw $e; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | public function delete() |
106 | 106 | { |
107 | - try{ |
|
107 | + try { |
|
108 | 108 | $id = $this->request->getAttribute('id'); |
109 | 109 | $this->categoryService->delete($id); |
110 | 110 | |
111 | 111 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
112 | 112 | } |
113 | - catch(\Exception $e){ |
|
113 | + catch (\Exception $e) { |
|
114 | 114 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories')); |
115 | 115 | } |
116 | 116 | } |
@@ -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 |