@@ -14,8 +14,8 @@ |
||
| 14 | 14 | public function __invoke(ContainerInterface $container) |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - $config = $container->get('config')['upload']; |
|
| 18 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 17 | + $config = $container->get('config')[ 'upload' ]; |
|
| 18 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 19 | 19 | |
| 20 | 20 | // Create pagination object |
| 21 | 21 | $pageMapper = $container->get(PageMapper::class); |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | + ['main_img' => $this->upload->uploadImage($data, 'main_img')]; |
| 78 | 78 | $data['page_id'] = Uuid::uuid1()->toString(); |
| 79 | 79 | $data['page_uuid'] |
| 80 | - = (new MysqlUuid($data['page_id']))->toFormat(new Binary); |
|
| 80 | + = (new MysqlUuid($data['page_id']))->toFormat(new Binary); |
|
| 81 | 81 | |
| 82 | 82 | if($data['is_homepage']){ |
| 83 | 83 | $this->pageMapper->update(['is_homepage' => false]); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function getPage($pageId) |
| 42 | 42 | { |
| 43 | - return $this->pageMapper->select(['page_id' => $pageId])->current(); |
|
| 43 | + return $this->pageMapper->select([ 'page_id' => $pageId ])->current(); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function getHomepage() |
| 59 | 59 | { |
| 60 | - return $this->pageMapper->select(['is_homepage' => true])->current(); |
|
| 60 | + return $this->pageMapper->select([ 'is_homepage' => true ])->current(); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -69,18 +69,18 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $filter = $this->pageFilter->getInputFilter()->setData($data); |
| 71 | 71 | |
| 72 | - if(!$filter->isValid()){ |
|
| 72 | + if (!$filter->isValid()) { |
|
| 73 | 73 | throw new FilterException($filter->getMessages()); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $data = $filter->getValues() |
| 77 | - + ['main_img' => $this->upload->uploadImage($data, 'main_img')]; |
|
| 78 | - $data['page_id'] = Uuid::uuid1()->toString(); |
|
| 79 | - $data['page_uuid'] |
|
| 80 | - = (new MysqlUuid($data['page_id']))->toFormat(new Binary); |
|
| 77 | + + [ 'main_img' => $this->upload->uploadImage($data, 'main_img') ]; |
|
| 78 | + $data[ 'page_id' ] = Uuid::uuid1()->toString(); |
|
| 79 | + $data[ 'page_uuid' ] |
|
| 80 | + = (new MysqlUuid($data[ 'page_id' ]))->toFormat(new Binary); |
|
| 81 | 81 | |
| 82 | - if($data['is_homepage']){ |
|
| 83 | - $this->pageMapper->update(['is_homepage' => false]); |
|
| 82 | + if ($data[ 'is_homepage' ]) { |
|
| 83 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $this->pageMapper->insert($data); |
@@ -88,42 +88,42 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function updatePage($data, $pageId) |
| 90 | 90 | { |
| 91 | - if(!($page = $this->getPage($pageId))){ |
|
| 91 | + if (!($page = $this->getPage($pageId))) { |
|
| 92 | 92 | throw new \Exception('Page object not found. Page ID:' . $pageId); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $filter = $this->pageFilter->getInputFilter()->setData($data); |
| 96 | 96 | |
| 97 | - if(!$filter->isValid()){ |
|
| 97 | + if (!$filter->isValid()) { |
|
| 98 | 98 | throw new FilterException($filter->getMessages()); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $data = $filter->getValues() |
| 102 | - + ['main_img' => $this->upload->uploadImage($data, 'main_img')]; |
|
| 102 | + + [ 'main_img' => $this->upload->uploadImage($data, 'main_img') ]; |
|
| 103 | 103 | |
| 104 | 104 | // We don't want to force user to re-upload image on edit |
| 105 | - if(!$data['main_img']){ |
|
| 106 | - unset($data['main_img']); |
|
| 105 | + if (!$data[ 'main_img' ]) { |
|
| 106 | + unset($data[ 'main_img' ]); |
|
| 107 | 107 | } |
| 108 | - else{ |
|
| 108 | + else { |
|
| 109 | 109 | $this->upload->deleteFile($page->getMainImg()); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if($data['is_homepage']){ |
|
| 113 | - $this->pageMapper->update(['is_homepage' => false]); |
|
| 112 | + if ($data[ 'is_homepage' ]) { |
|
| 113 | + $this->pageMapper->update([ 'is_homepage' => false ]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - return $this->pageMapper->update($data, ['page_id' => $pageId]); |
|
| 116 | + return $this->pageMapper->update($data, [ 'page_id' => $pageId ]); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | public function delete($pageId) |
| 120 | 120 | { |
| 121 | - if(!($page = $this->getPage($pageId))){ |
|
| 121 | + if (!($page = $this->getPage($pageId))) { |
|
| 122 | 122 | throw new \Exception('Page not found'); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $this->upload->deleteFile($page->getMainImg()); |
| 126 | 126 | |
| 127 | - return (bool)$this->pageMapper->delete(['page_id' => $pageId]); |
|
| 127 | + return (bool) $this->pageMapper->delete([ 'page_id' => $pageId ]); |
|
| 128 | 128 | } |
| 129 | 129 | } |
@@ -104,8 +104,7 @@ |
||
| 104 | 104 | // We don't want to force user to re-upload image on edit |
| 105 | 105 | if(!$data['main_img']){ |
| 106 | 106 | unset($data['main_img']); |
| 107 | - } |
|
| 108 | - else{ |
|
| 107 | + } else{ |
|
| 109 | 108 | $this->upload->deleteFile($page->getMainImg()); |
| 110 | 109 | } |
| 111 | 110 | |