@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Article\Mapper; |
| 5 | 5 | |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | public function getPaginationSelect($isActive = null) |
| 35 | 35 | { |
| 36 | 36 | $select = $this->getSql()->select() |
| 37 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['slug', 'published_at', 'status', 'article_id']) |
|
| 38 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name']) |
|
| 39 | - ->where(['articles.type' => ArticleType::VIDEO]) |
|
| 40 | - ->order(['articles.created_at' => 'desc']); |
|
| 37 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'slug', 'published_at', 'status', 'article_id' ]) |
|
| 38 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name' ]) |
|
| 39 | + ->where([ 'articles.type' => ArticleType::VIDEO ]) |
|
| 40 | + ->order([ 'articles.created_at' => 'desc' ]); |
|
| 41 | 41 | |
| 42 | - if($isActive !== null) { |
|
| 43 | - $select->where(['articles.status' => (int)$isActive]); |
|
| 42 | + if ($isActive !== null) { |
|
| 43 | + $select->where([ 'articles.status' => (int) $isActive ]); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $select; |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | public function get($id) |
| 50 | 50 | { |
| 51 | 51 | $select = $this->getSql()->select() |
| 52 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title']) |
|
| 52 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title' ]) |
|
| 53 | 53 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
| 54 | 54 | ->join('category', 'category.category_uuid = articles.category_uuid', |
| 55 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left') |
|
| 56 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
| 57 | - ->where(['articles.article_id' => $id]); |
|
| 55 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left') |
|
| 56 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
| 57 | + ->where([ 'articles.article_id' => $id ]); |
|
| 58 | 58 | |
| 59 | 59 | return $this->selectWith($select)->current(); |
| 60 | 60 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | public function getLatest($limit = 50) |
| 63 | 63 | { |
| 64 | 64 | $select = $this->getSql()->select() |
| 65 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
| 66 | - ->where(['articles.status' => 1]) |
|
| 67 | - ->order(['published_at' => 'desc']) |
|
| 65 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
| 66 | + ->where([ 'articles.status' => 1 ]) |
|
| 67 | + ->order([ 'published_at' => 'desc' ]) |
|
| 68 | 68 | ->limit($limit); |
| 69 | 69 | |
| 70 | 70 | return $this->selectWith($select); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $select = $this->getSql()->select() |
| 76 | 76 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
| 77 | - ->where(['articles.slug' => $slug]); |
|
| 77 | + ->where([ 'articles.slug' => $slug ]); |
|
| 78 | 78 | |
| 79 | 79 | return $this->selectWith($select)->current(); |
| 80 | 80 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | return [ |
| 12 | 12 | 'templates' => [ |
| 13 | 13 | 'paths' => [ |
| 14 | - 'article' => [__DIR__ . '/../templates/article'], |
|
| 14 | + 'article' => [ __DIR__ . '/../templates/article' ], |
|
| 15 | 15 | ], |
| 16 | 16 | ], |
| 17 | 17 | |
@@ -51,49 +51,49 @@ discard block |
||
| 51 | 51 | 'name' => 'admin.posts', |
| 52 | 52 | 'path' => '/admin/posts', |
| 53 | 53 | 'middleware' => Controller\PostController::class, |
| 54 | - 'allowed_methods' => ['GET'], |
|
| 54 | + 'allowed_methods' => [ 'GET' ], |
|
| 55 | 55 | ], |
| 56 | 56 | [ |
| 57 | 57 | 'name' => 'admin.posts.action', |
| 58 | 58 | 'path' => '/admin/posts/:action/:id', |
| 59 | 59 | 'middleware' => Controller\PostController::class, |
| 60 | - 'allowed_methods' => ['GET', 'POST'], |
|
| 60 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
| 61 | 61 | ], |
| 62 | 62 | [ |
| 63 | 63 | 'name' => 'admin.discussions', |
| 64 | 64 | 'path' => '/admin/discussions', |
| 65 | 65 | 'middleware' => Controller\DiscussionController::class, |
| 66 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 66 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 67 | 67 | ], |
| 68 | 68 | [ |
| 69 | 69 | 'name' => 'admin.discussions.action', |
| 70 | 70 | 'path' => '/admin/discussions/:action/:id', |
| 71 | 71 | 'middleware' => Controller\DiscussionController::class, |
| 72 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 72 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 73 | 73 | ], |
| 74 | 74 | [ |
| 75 | 75 | 'name' => 'admin.events', |
| 76 | 76 | 'path' => '/admin/events', |
| 77 | 77 | 'middleware' => Controller\EventController::class, |
| 78 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 78 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 79 | 79 | ], |
| 80 | 80 | [ |
| 81 | 81 | 'name' => 'admin.events.action', |
| 82 | 82 | 'path' => '/admin/events/:action/:id', |
| 83 | 83 | 'middleware' => Controller\EventController::class, |
| 84 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 84 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 85 | 85 | ], |
| 86 | 86 | [ |
| 87 | 87 | 'name' => 'admin.videos', |
| 88 | 88 | 'path' => '/admin/videos', |
| 89 | 89 | 'middleware' => Controller\VideoController::class, |
| 90 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 90 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 91 | 91 | ], |
| 92 | 92 | [ |
| 93 | 93 | 'name' => 'admin.videos.action', |
| 94 | 94 | 'path' => '/admin/videos/:action/:id', |
| 95 | 95 | 'middleware' => Controller\VideoController::class, |
| 96 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 96 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 97 | 97 | ] |
| 98 | 98 | ], |
| 99 | 99 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Article\Factory\Service; |
| 5 | 5 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __invoke(ContainerInterface $container): VideoService |
| 23 | 23 | { |
| 24 | - $config = $container->get('config')['upload']; |
|
| 25 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 24 | + $config = $container->get('config')[ 'upload' ]; |
|
| 25 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 26 | 26 | |
| 27 | 27 | return new VideoService( |
| 28 | 28 | $container->get(ArticleMapper::class), |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Article\Factory\Service; |
| 5 | 5 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __invoke(ContainerInterface $container): PostService |
| 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 PostService( |
| 27 | 27 | $container->get(ArticleMapper::class), |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public function __invoke(ContainerInterface $container) |
| 21 | 21 | { |
| 22 | - $config = $container->get('config')['upload']; |
|
| 23 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 22 | + $config = $container->get('config')[ 'upload' ]; |
|
| 23 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 24 | 24 | |
| 25 | 25 | return new EventService( |
| 26 | 26 | $container->get(ArticleMapper::class), |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Article\Factory\Controller; |
| 5 | 5 | |
@@ -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 | /** |
@@ -19,37 +19,37 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function getInputFilter() |
| 21 | 21 | { |
| 22 | - if(!$this->inputFilter){ |
|
| 22 | + if (!$this->inputFilter) { |
|
| 23 | 23 | $inputFilter = new InputFilter(); |
| 24 | 24 | |
| 25 | 25 | $inputFilter->add([ |
| 26 | 26 | 'name' => 'first_name', |
| 27 | 27 | 'required' => true, |
| 28 | - 'filters' => [['name' => 'StringTrim']], |
|
| 28 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 29 | 29 | 'validators' => [ |
| 30 | - ['name' => 'NotEmpty'], |
|
| 31 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]] |
|
| 30 | + [ 'name' => 'NotEmpty' ], |
|
| 31 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ] |
|
| 32 | 32 | ], |
| 33 | 33 | ]); |
| 34 | 34 | |
| 35 | 35 | $inputFilter->add([ |
| 36 | 36 | 'name' => 'last_name', |
| 37 | 37 | 'required' => true, |
| 38 | - 'filters' => [['name' => 'StringTrim']], |
|
| 38 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 39 | 39 | 'validators' => [ |
| 40 | - ['name' => 'NotEmpty'], |
|
| 41 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]] |
|
| 40 | + [ 'name' => 'NotEmpty' ], |
|
| 41 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ] |
|
| 42 | 42 | ], |
| 43 | 43 | ]); |
| 44 | 44 | |
| 45 | 45 | $inputFilter->add([ |
| 46 | 46 | 'name' => 'email', |
| 47 | 47 | 'required' => true, |
| 48 | - 'filters' => [['name' => 'StringTrim']], |
|
| 48 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 49 | 49 | 'validators' => [ |
| 50 | - ['name' => 'NotEmpty'], |
|
| 51 | - ['name' => 'EmailAddress'], |
|
| 52 | - ['name' => 'dbnorecordexists', 'options' => ['adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email']], |
|
| 50 | + [ 'name' => 'NotEmpty' ], |
|
| 51 | + [ 'name' => 'EmailAddress' ], |
|
| 52 | + [ 'name' => 'dbnorecordexists', 'options' => [ 'adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email' ] ], |
|
| 53 | 53 | |
| 54 | 54 | ], |
| 55 | 55 | ]); |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | $inputFilter->add([ |
| 58 | 58 | 'name' => 'introduction', |
| 59 | 59 | 'required' => false, |
| 60 | - 'filters' => [['name' => 'StringTrim']] |
|
| 60 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 61 | 61 | ]); |
| 62 | 62 | |
| 63 | 63 | $inputFilter->add([ |
| 64 | 64 | 'name' => 'biography', |
| 65 | 65 | 'required' => false, |
| 66 | - 'filters' => [['name' => 'StringTrim']] |
|
| 66 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 67 | 67 | ]); |
| 68 | 68 | |
| 69 | 69 | $inputFilter->add([ |
| 70 | 70 | 'name' => 'password', |
| 71 | 71 | 'required' => true, |
| 72 | 72 | 'validators' => [ |
| 73 | - ['name' => 'NotEmpty'], |
|
| 74 | - ['name' => 'StringLength', 'options' => ['min' => 7, 'max' => 255]] |
|
| 73 | + [ 'name' => 'NotEmpty' ], |
|
| 74 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 7, 'max' => 255 ] ] |
|
| 75 | 75 | ], |
| 76 | 76 | ]); |
| 77 | 77 | |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | 'name' => 'confirm_password', |
| 80 | 80 | 'required' => true, |
| 81 | 81 | 'validators' => [ |
| 82 | - ['name' => 'NotEmpty'], |
|
| 83 | - ['name' => 'Identical', 'options' => ['token' => 'password']], |
|
| 82 | + [ 'name' => 'NotEmpty' ], |
|
| 83 | + [ 'name' => 'Identical', 'options' => [ 'token' => 'password' ] ], |
|
| 84 | 84 | ], |
| 85 | 85 | ]); |
| 86 | 86 | |
| 87 | 87 | $inputFilter->add([ |
| 88 | 88 | 'name' => 'status', |
| 89 | 89 | 'required' => true, |
| 90 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Digits']] |
|
| 90 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Digits' ] ] |
|
| 91 | 91 | ]); |
| 92 | 92 | |
| 93 | 93 | $this->inputFilter = $inputFilter; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | public function getMessages(array $msgs) |
| 20 | 20 | { |
| 21 | 21 | $allMsgs = ''; |
| 22 | - array_walk_recursive($msgs, function ($value) use (&$allMsgs){ |
|
| 22 | + array_walk_recursive($msgs, function($value) use (&$allMsgs){ |
|
| 23 | 23 | $allMsgs .= "- " . $value . "<br/>"; |
| 24 | 24 | }); |
| 25 | 25 | |