@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Core\Service; |
| 5 | 5 | |
@@ -61,17 +61,17 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function loginUser($email, $password) |
| 63 | 63 | { |
| 64 | - if(!$email || !$password) { |
|
| 64 | + if (!$email || !$password) { |
|
| 65 | 65 | throw new \Exception('Both email and password are required.', 400); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $user = $this->adminUsersMapper->getByEmail($email); |
| 69 | 69 | |
| 70 | - if(!$user) { |
|
| 70 | + if (!$user) { |
|
| 71 | 71 | throw new \Exception('User does not exist.'); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if(!$this->crypt->verify($password, $user->password)) { |
|
| 74 | + if (!$this->crypt->verify($password, $user->password)) { |
|
| 75 | 75 | throw new \Exception('Password does not match.'); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
| 119 | 119 | |
| 120 | - if(!$filter->isValid()) { |
|
| 120 | + if (!$filter->isValid()) { |
|
| 121 | 121 | throw new FilterException($filter->getMessages()); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | 'profile_img' => $this->upload->uploadImage($data, 'profile_img') |
| 127 | 127 | ]; |
| 128 | 128 | |
| 129 | - unset($data['confirm_password']); |
|
| 130 | - $data['password'] = $this->crypt->create($data['password']); |
|
| 131 | - $data['admin_user_id'] = Uuid::uuid1()->toString(); |
|
| 132 | - $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary); |
|
| 129 | + unset($data[ 'confirm_password' ]); |
|
| 130 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
| 131 | + $data[ 'admin_user_id' ] = Uuid::uuid1()->toString(); |
|
| 132 | + $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary); |
|
| 133 | 133 | |
| 134 | 134 | return $this->adminUsersMapper->insert($data); |
| 135 | 135 | } |
@@ -143,17 +143,17 @@ discard block |
||
| 143 | 143 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
| 144 | 144 | |
| 145 | 145 | // we dont want to force user to enter the password again |
| 146 | - if($data['password'] == '') { |
|
| 146 | + if ($data[ 'password' ] == '') { |
|
| 147 | 147 | $filter->remove('password'); |
| 148 | 148 | $filter->remove('confirm_password'); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // if we want to keep same email |
| 152 | - if($user->email == $data['email']) { |
|
| 152 | + if ($user->email == $data[ 'email' ]) { |
|
| 153 | 153 | $filter->remove('email'); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if(!$filter->isValid()) { |
|
| 156 | + if (!$filter->isValid()) { |
|
| 157 | 157 | throw new FilterException($filter->getMessages()); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | ]; |
| 164 | 164 | |
| 165 | 165 | // We dont want to force user to re-upload image on edit |
| 166 | - if(!$data['face_img']) { |
|
| 167 | - unset($data['face_img']); |
|
| 166 | + if (!$data[ 'face_img' ]) { |
|
| 167 | + unset($data[ 'face_img' ]); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(!$data['profile_img']) { |
|
| 171 | - unset($data['profile_img']); |
|
| 170 | + if (!$data[ 'profile_img' ]) { |
|
| 171 | + unset($data[ 'profile_img' ]); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if(isset($data['password'])) { |
|
| 175 | - unset($data['confirm_password']); |
|
| 176 | - $data['password'] = $this->crypt->create($data['password']); |
|
| 174 | + if (isset($data[ 'password' ])) { |
|
| 175 | + unset($data[ 'confirm_password' ]); |
|
| 176 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]); |
|
| 179 | + return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function delete($userId) |
| 189 | 189 | { |
| 190 | - return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]); |
|
| 190 | + return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Core\Mapper; |
| 5 | 5 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function get($id) |
| 35 | 35 | { |
| 36 | - return $this->select(['admin_user_id' => $id])->current(); |
|
| 36 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function getByEmail(string $email) |
| 46 | 46 | { |
| 47 | - return $this->select(['email' => $email])->current(); |
|
| 47 | + return $this->select([ 'email' => $email ])->current(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function updateLogin(string $userId): int |
| 57 | 57 | { |
| 58 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
| 58 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function getPaginationSelect($userId) |
| 62 | 62 | { |
| 63 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
| 63 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
| 64 | 64 | |
| 65 | 65 | $select->where->notEqualTo('admin_user_id', $userId); |
| 66 | 66 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function getRandom($limit) |
| 71 | 71 | { |
| 72 | 72 | $select = $this->getSql()->select() |
| 73 | - ->where(['status' => 1]) |
|
| 73 | + ->where([ 'status' => 1 ]) |
|
| 74 | 74 | ->order(new Expression('rand()')) |
| 75 | 75 | ->limit($limit); |
| 76 | 76 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Core\Factory\Service; |
| 5 | 5 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __invoke(ContainerInterface $container): AdminUserService |
| 22 | 22 | { |
| 23 | - $config = $container->get('config')['upload']; |
|
| 24 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 23 | + $config = $container->get('config')[ 'upload' ]; |
|
| 24 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 25 | 25 | |
| 26 | 26 | return new AdminUserService( |
| 27 | 27 | new Bcrypt(), |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | |
| 10 | 10 | public function up() |
| 11 | 11 | { |
| 12 | - $this->table('category', ['id' => false, 'primary_key' => 'category_uuid']) |
|
| 13 | - ->addColumn('category_uuid', 'binary', ['limit' => 16]) |
|
| 12 | + $this->table('category', [ 'id' => false, 'primary_key' => 'category_uuid' ]) |
|
| 13 | + ->addColumn('category_uuid', 'binary', [ 'limit' => 16 ]) |
|
| 14 | 14 | ->addColumn('category_id', 'text') |
| 15 | 15 | ->addColumn('name', 'text') |
| 16 | 16 | ->addColumn('slug', 'text') |
@@ -12,56 +12,56 @@ |
||
| 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' => 'title', |
| 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' => 'sub_title', |
| 30 | 30 | 'required' => false, |
| 31 | - 'filters' => [['name' => 'StringTrim']], |
|
| 31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 32 | 32 | 'validators' => [ |
| 33 | - ['name' => 'NotEmpty'], |
|
| 34 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 500]], |
|
| 33 | + [ 'name' => 'NotEmpty' ], |
|
| 34 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 500 ] ], |
|
| 35 | 35 | ], |
| 36 | 36 | ]); |
| 37 | 37 | |
| 38 | 38 | $inputFilter->add([ |
| 39 | 39 | 'name' => 'body', |
| 40 | 40 | 'required' => true, |
| 41 | - 'filters' => [['name' => 'StringTrim']], |
|
| 41 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 42 | 42 | 'validators' => [ |
| 43 | - ['name' => 'NotEmpty'], |
|
| 44 | - ['name' => 'StringLength', 'options' => ['min' => 2]], |
|
| 43 | + [ 'name' => 'NotEmpty' ], |
|
| 44 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2 ] ], |
|
| 45 | 45 | ], |
| 46 | 46 | ]); |
| 47 | 47 | |
| 48 | 48 | $inputFilter->add([ |
| 49 | 49 | 'name' => 'lead', |
| 50 | 50 | 'required' => true, |
| 51 | - 'filters' => [['name' => 'StringTrim']], |
|
| 51 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 52 | 52 | 'validators' => [ |
| 53 | - ['name' => 'NotEmpty'], |
|
| 54 | - ['name' => 'StringLength', 'options' => ['min' => 2]], |
|
| 53 | + [ 'name' => 'NotEmpty' ], |
|
| 54 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2 ] ], |
|
| 55 | 55 | ], |
| 56 | 56 | ]); |
| 57 | 57 | |
| 58 | 58 | $inputFilter->add([ |
| 59 | 59 | 'name' => 'video_url', |
| 60 | 60 | 'required' => true, |
| 61 | - 'filters' => [['name' => 'StringTrim']], |
|
| 61 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 62 | 62 | 'validators' => [ |
| 63 | - ['name' => 'NotEmpty'], |
|
| 64 | - ['name' => 'StringLength'], |
|
| 63 | + [ 'name' => 'NotEmpty' ], |
|
| 64 | + [ 'name' => 'StringLength' ], |
|
| 65 | 65 | ], |
| 66 | 66 | ]); |
| 67 | 67 | |
@@ -12,73 +12,73 @@ |
||
| 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' => 'title', |
| 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' => 'sub_title', |
| 30 | 30 | 'required' => false, |
| 31 | - 'filters' => [['name' => 'StringTrim']] |
|
| 31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 32 | 32 | ]); |
| 33 | 33 | |
| 34 | 34 | $inputFilter->add([ |
| 35 | 35 | 'name' => 'place_name', |
| 36 | 36 | 'required' => true, |
| 37 | - 'filters' => [['name' => 'StringTrim']] |
|
| 37 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 38 | 38 | ]); |
| 39 | 39 | |
| 40 | 40 | $inputFilter->add([ |
| 41 | 41 | 'name' => 'event_url', |
| 42 | 42 | 'required' => false, |
| 43 | - 'filters' => [['name' => 'StringTrim']] |
|
| 43 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 44 | 44 | ]); |
| 45 | 45 | |
| 46 | 46 | $inputFilter->add([ |
| 47 | 47 | 'name' => 'body', |
| 48 | 48 | 'required' => true, |
| 49 | - 'filters' => [['name' => 'StringTrim']], |
|
| 49 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 50 | 50 | 'validators' => [ |
| 51 | - ['name' => 'NotEmpty'], |
|
| 52 | - ['name' => 'StringLength', 'options' => ['min' => 2]], |
|
| 51 | + [ 'name' => 'NotEmpty' ], |
|
| 52 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2 ] ], |
|
| 53 | 53 | ], |
| 54 | 54 | ]); |
| 55 | 55 | |
| 56 | 56 | $inputFilter->add([ |
| 57 | 57 | 'name' => 'start_at', |
| 58 | 58 | 'required' => true, |
| 59 | - 'filters' => [['name' => 'StringTrim']], |
|
| 60 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
| 59 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 60 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
| 61 | 61 | ]); |
| 62 | 62 | |
| 63 | 63 | $inputFilter->add([ |
| 64 | 64 | 'name' => 'end_at', |
| 65 | 65 | 'required' => true, |
| 66 | - 'filters' => [['name' => 'StringTrim']], |
|
| 67 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
| 66 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 67 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
| 68 | 68 | ]); |
| 69 | 69 | |
| 70 | 70 | $inputFilter->add([ |
| 71 | 71 | 'name' => 'longitude', |
| 72 | 72 | 'required' => true, |
| 73 | - 'filters' => [['name' => 'StringTrim']], |
|
| 74 | - 'validators' => [['name' => 'NotEmpty']], |
|
| 73 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 74 | + 'validators' => [ [ 'name' => 'NotEmpty' ] ], |
|
| 75 | 75 | ]); |
| 76 | 76 | |
| 77 | 77 | $inputFilter->add([ |
| 78 | 78 | 'name' => 'latitude', |
| 79 | 79 | 'required' => true, |
| 80 | - 'filters' => [['name' => 'StringTrim']], |
|
| 81 | - 'validators' => [['name' => 'NotEmpty']], |
|
| 80 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 81 | + 'validators' => [ [ 'name' => 'NotEmpty' ] ], |
|
| 82 | 82 | ]); |
| 83 | 83 | |
| 84 | 84 | $this->inputFilter = $inputFilter; |
@@ -12,24 +12,24 @@ discard block |
||
| 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' => 'slug', |
| 20 | 20 | 'required' => true, |
| 21 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
| 21 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
| 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' => 'published_at', |
| 30 | 30 | 'required' => true, |
| 31 | - 'filters' => [['name' => 'StringTrim']], |
|
| 32 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
| 31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 32 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
| 33 | 33 | ]); |
| 34 | 34 | |
| 35 | 35 | $inputFilter->add([ |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | $inputFilter->add([ |
| 41 | 41 | 'name' => 'status', |
| 42 | 42 | 'required' => false, |
| 43 | - 'filters' => [['name' => 'Boolean']], |
|
| 43 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 44 | 44 | ]); |
| 45 | 45 | |
| 46 | 46 | $inputFilter->add([ |
| 47 | 47 | 'name' => 'is_wysiwyg_editor', |
| 48 | 48 | 'required' => false, |
| 49 | - 'filters' => [['name' => 'Boolean']], |
|
| 49 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 50 | 50 | ]); |
| 51 | 51 | |
| 52 | 52 | $this->inputFilter = $inputFilter; |
@@ -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 Article\Service; |
| 6 | 6 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 112 | 112 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
| 113 | 113 | |
| 114 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 114 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 115 | 115 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | 'article_uuid' => $uuId |
| 125 | 125 | ]; |
| 126 | 126 | |
| 127 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 128 | - unset($article['category_id']); |
|
| 127 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 128 | + unset($article[ 'category_id' ]); |
|
| 129 | 129 | |
| 130 | 130 | $videos = $videosFilter->getValues() + [ |
| 131 | 131 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -143,40 +143,40 @@ discard block |
||
| 143 | 143 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
| 144 | 144 | $videosFilter = $this->videosFilter->getInputFilter()->setData($data); |
| 145 | 145 | |
| 146 | - if(!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 146 | + if (!$articleFilter->isValid() || !$videosFilter->isValid()) { |
|
| 147 | 147 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
| 151 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 152 | - unset($article['category_id']); |
|
| 150 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
| 151 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 152 | + unset($article[ 'category_id' ]); |
|
| 153 | 153 | $videos = $videosFilter->getValues() + [ |
| 154 | 154 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 155 | 155 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
| 156 | 156 | ]; |
| 157 | 157 | |
| 158 | 158 | // We dont want to force user to re-upload image on edit |
| 159 | - if(!$videos['featured_img']) { |
|
| 160 | - unset($videos['featured_img']); |
|
| 159 | + if (!$videos[ 'featured_img' ]) { |
|
| 160 | + unset($videos[ 'featured_img' ]); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if(!$videos['main_img']) { |
|
| 164 | - unset($videos['main_img']); |
|
| 163 | + if (!$videos[ 'main_img' ]) { |
|
| 164 | + unset($videos[ 'main_img' ]); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 168 | - $this->articleVideosMapper->update($videos, ['article_uuid' => $article['article_uuid']]); |
|
| 167 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 168 | + $this->articleVideosMapper->update($videos, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | public function deleteArticle($id) |
| 172 | 172 | { |
| 173 | 173 | $video = $this->articleVideosMapper->get($id); |
| 174 | 174 | |
| 175 | - if(!$video) { |
|
| 175 | + if (!$video) { |
|
| 176 | 176 | throw new \Exception('Article not found!'); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $this->articleVideosMapper->delete(['article_uuid' => $video->article_uuid]); |
|
| 179 | + $this->articleVideosMapper->delete([ 'article_uuid' => $video->article_uuid ]); |
|
| 180 | 180 | $this->delete($video->article_uuid); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function getCategoryIds($articleId) |
| 33 | 33 | { |
| 34 | - $categories = []; |
|
| 35 | - foreach($this->articleMapper->getCategories($articleId) as $category) { |
|
| 36 | - $categories[] = $category->category_id; |
|
| 34 | + $categories = [ ]; |
|
| 35 | + foreach ($this->articleMapper->getCategories($articleId) as $category) { |
|
| 36 | + $categories[ ] = $category->category_id; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return $categories; |
@@ -41,6 +41,6 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function delete($articleId) |
| 43 | 43 | { |
| 44 | - $this->articleMapper->delete(['article_uuid' => $articleId]); |
|
| 44 | + $this->articleMapper->delete([ 'article_uuid' => $articleId ]); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |