@@ -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 | } |
@@ -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 | ]; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Category\Service; |
| 5 | 5 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function getCategoryBySlug($urlSlug) |
| 71 | 71 | { |
| 72 | - return $this->categoryMapper->select(['slug' => $urlSlug])->current(); |
|
| 72 | + return $this->categoryMapper->select([ 'slug' => $urlSlug ])->current(); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $filter = $this->categoryFilter->getInputFilter()->setData($data); |
| 84 | 84 | |
| 85 | - if(!$filter->isValid()) { |
|
| 85 | + if (!$filter->isValid()) { |
|
| 86 | 86 | throw new FilterException($filter->getMessages()); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $data = $filter->getValues(); |
| 90 | - $data['category_id'] = Uuid::uuid1()->toString(); |
|
| 91 | - $data['category_uuid'] = (new MysqlUuid($data['category_id']))->toFormat(new Binary); |
|
| 90 | + $data[ 'category_id' ] = Uuid::uuid1()->toString(); |
|
| 91 | + $data[ 'category_uuid' ] = (new MysqlUuid($data[ 'category_id' ]))->toFormat(new Binary); |
|
| 92 | 92 | |
| 93 | 93 | $this->categoryMapper->insert($data); |
| 94 | 94 | } |
@@ -103,18 +103,18 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function updateCategory($data, $categoryId) |
| 105 | 105 | { |
| 106 | - if(!$this->getCategory($categoryId)) { |
|
| 106 | + if (!$this->getCategory($categoryId)) { |
|
| 107 | 107 | throw new \Exception('CategoryId dos not exist.'); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $filter = $this->categoryFilter->getInputFilter()->setData($data); |
| 111 | 111 | |
| 112 | - if(!$filter->isValid()) { |
|
| 112 | + if (!$filter->isValid()) { |
|
| 113 | 113 | throw new FilterException($filter->getMessages()); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $data = $filter->getValues(); |
| 117 | - $this->categoryMapper->update($data, ['category_id' => $categoryId]); |
|
| 117 | + $this->categoryMapper->update($data, [ 'category_id' => $categoryId ]); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function delete($categoryId) |
| 127 | 127 | { |
| 128 | - return (bool)$this->categoryMapper->delete(['category_id' => $categoryId]); |
|
| 128 | + return (bool) $this->categoryMapper->delete([ 'category_id' => $categoryId ]); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $categories = $this->categoryMapper->getWeb()->toArray(); |
| 147 | 147 | |
| 148 | - foreach($categories as $ctn => $category) { |
|
| 149 | - $select = $this->categoryMapper->getCategoryPostsSelect($category['category_id'], 4); |
|
| 148 | + foreach ($categories as $ctn => $category) { |
|
| 149 | + $select = $this->categoryMapper->getCategoryPostsSelect($category[ 'category_id' ], 4); |
|
| 150 | 150 | $posts = $this->categoryMapper->selectWith($select)->toArray(); |
| 151 | - $categories[$ctn]['posts'] = $posts; |
|
| 151 | + $categories[ $ctn ][ 'posts' ] = $posts; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $categories; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function allWeb() |
| 161 | 161 | { |
| 162 | - return $this->categoryMapper->getWeb(null, ['name' => 'asc']); |
|
| 162 | + return $this->categoryMapper->getWeb(null, [ 'name' => 'asc' ]); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -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 | } |
@@ -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 | |