@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | |
40 | 40 | public function getPage($pageId) |
41 | 41 | { |
42 | - return $this->pageMapper->select(['page_id' => $pageId])->current(); |
|
42 | + return $this->pageMapper->select([ 'page_id' => $pageId ])->current(); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getHomepage() |
46 | 46 | { |
47 | - return $this->pageMapper->select(['is_homepage' => true])->current(); |
|
47 | + return $this->pageMapper->select([ 'is_homepage' => true ])->current(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function createPage($data) |
51 | 51 | { |
52 | 52 | $filter = $this->pageFilter->getInputFilter()->setData($data); |
53 | 53 | |
54 | - if(!$filter->isValid()) { |
|
54 | + if (!$filter->isValid()) { |
|
55 | 55 | throw new FilterException($filter->getMessages()); |
56 | 56 | } |
57 | 57 | |
58 | - $data = $filter->getValues() + ['main_img' => $this->upload->uploadImage($data, 'main_img')]; |
|
59 | - $data['page_id'] = Uuid::uuid1()->toString(); |
|
60 | - $data['page_uuid'] = (new MysqlUuid($data['page_id']))->toFormat(new Binary); |
|
58 | + $data = $filter->getValues() + [ 'main_img' => $this->upload->uploadImage($data, 'main_img') ]; |
|
59 | + $data[ 'page_id' ] = Uuid::uuid1()->toString(); |
|
60 | + $data[ 'page_uuid' ] = (new MysqlUuid($data[ 'page_id' ]))->toFormat(new Binary); |
|
61 | 61 | |
62 | - if($data['is_homepage']) { |
|
63 | - $this->pageMapper->update(['is_homepage' => false]); |
|
62 | + if ($data[ 'is_homepage' ]) { |
|
63 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $this->pageMapper->insert($data); |
@@ -68,32 +68,32 @@ discard block |
||
68 | 68 | |
69 | 69 | public function updatePage($data, $pageId) |
70 | 70 | { |
71 | - if(!($page = $this->getPage($pageId))) { |
|
71 | + if (!($page = $this->getPage($pageId))) { |
|
72 | 72 | throw new \Exception('Page object not found. Page ID:' . $pageId); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $filter = $this->pageFilter->getInputFilter()->setData($data); |
76 | 76 | |
77 | - if(!$filter->isValid()) { |
|
77 | + if (!$filter->isValid()) { |
|
78 | 78 | throw new FilterException($filter->getMessages()); |
79 | 79 | } |
80 | 80 | |
81 | - $data = $filter->getValues() + ['main_img' => $this->upload->uploadImage($data, 'main_img'),]; |
|
81 | + $data = $filter->getValues() + [ 'main_img' => $this->upload->uploadImage($data, 'main_img'), ]; |
|
82 | 82 | |
83 | 83 | // We don't want to force user to re-upload image on edit |
84 | - if(!$data['main_img']) { |
|
85 | - unset($data['main_img']); |
|
84 | + if (!$data[ 'main_img' ]) { |
|
85 | + unset($data[ 'main_img' ]); |
|
86 | 86 | } |
87 | 87 | |
88 | - if($data['is_homepage']) { |
|
89 | - $this->pageMapper->update(['is_homepage' => false]); |
|
88 | + if ($data[ 'is_homepage' ]) { |
|
89 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
90 | 90 | } |
91 | 91 | |
92 | - return $this->pageMapper->update($data, ['page_id' => $pageId]); |
|
92 | + return $this->pageMapper->update($data, [ 'page_id' => $pageId ]); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | public function delete($pageId) |
96 | 96 | { |
97 | - return (bool)$this->pageMapper->delete(['page_id' => $pageId]); |
|
97 | + return (bool) $this->pageMapper->delete([ 'page_id' => $pageId ]); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Action; |
6 | 6 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $page = $this->pageService->getHomepage(); |
50 | 50 | |
51 | - return new HtmlResponse($this->template->render('web::home', ['page' => $page, 'layout' => 'layout/web'])); |
|
51 | + return new HtmlResponse($this->template->render('web::home', [ 'page' => $page, 'layout' => 'layout/web' ])); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |