@@ -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 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function __invoke(Request $request, Response $response, callable $next = null): HtmlResponse |
| 47 | 47 | { |
| 48 | 48 | // Set custom html from view file |
| 49 | - return new HtmlResponse($this->template->render('web::home', ['layout' => 'layout/web'])); |
|
| 49 | + return new HtmlResponse($this->template->render('web::home', [ 'layout' => 'layout/web' ])); |
|
| 50 | 50 | |
| 51 | 51 | //$article = $this->postService->getHomepage(); |
| 52 | 52 | // |
@@ -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 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function __invoke(Request $request, Response $response, callable $next = null) |
| 52 | 52 | { |
| 53 | 53 | $params = $request->getQueryParams(); |
| 54 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
| 54 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
| 55 | 55 | $videos = $this->videoService->fetchWebArticles($page, 5); |
| 56 | 56 | |
| 57 | 57 | return new HtmlResponse($this->template->render('web::videos', [ |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | 'admin/pagination' => __DIR__ . '/../templates/admin/partial/pagination.phtml', |
| 14 | 14 | ], |
| 15 | 15 | 'paths' => [ |
| 16 | - 'admin' => [__DIR__ . '/../templates/admin'], |
|
| 16 | + 'admin' => [ __DIR__ . '/../templates/admin' ], |
|
| 17 | 17 | ], |
| 18 | 18 | ], |
| 19 | 19 | |
@@ -30,25 +30,25 @@ discard block |
||
| 30 | 30 | 'name' => 'auth', |
| 31 | 31 | 'path' => '/auth/:action', |
| 32 | 32 | 'middleware' => Controller\AuthController::class, |
| 33 | - 'allowed_methods' => ['GET', 'POST'], |
|
| 33 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
| 34 | 34 | ], |
| 35 | 35 | [ |
| 36 | 36 | 'name' => 'admin', |
| 37 | 37 | 'path' => '/admin', |
| 38 | 38 | 'middleware' => Action\IndexAction::class, |
| 39 | - 'allowed_methods' => ['GET'], |
|
| 39 | + 'allowed_methods' => [ 'GET' ], |
|
| 40 | 40 | ], |
| 41 | 41 | [ |
| 42 | 42 | 'name' => 'admin.users', |
| 43 | 43 | 'path' => '/admin/users', |
| 44 | 44 | 'middleware' => Controller\UserController::class, |
| 45 | - 'allowed_methods' => ['GET'] |
|
| 45 | + 'allowed_methods' => [ 'GET' ] |
|
| 46 | 46 | ], |
| 47 | 47 | [ |
| 48 | 48 | 'name' => 'admin.users.action', |
| 49 | 49 | 'path' => '/admin/users/:action/:id', |
| 50 | 50 | 'middleware' => Controller\UserController::class, |
| 51 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 51 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 52 | 52 | ], |
| 53 | 53 | ], |
| 54 | 54 | |
@@ -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 Admin\Controller; |
| 6 | 6 | |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $user = $this->session->getStorage()->user; |
| 66 | 66 | $params = $this->request->getQueryParams(); |
| 67 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
| 68 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
| 67 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
| 68 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
| 69 | 69 | |
| 70 | 70 | $adminUsers = $this->adminUserService->getPagination($page, $limit, $user->admin_user_id); |
| 71 | 71 | |
| 72 | - return new HtmlResponse($this->template->render('admin::user/index', ['list' => $adminUsers, 'layout' => 'layout/admin'])); |
|
| 72 | + return new HtmlResponse($this->template->render('admin::user/index', [ 'list' => $adminUsers, 'layout' => 'layout/admin' ])); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return \Psr\Http\Message\ResponseInterface |
| 79 | 79 | */ |
| 80 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
| 80 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
| 81 | 81 | { |
| 82 | 82 | $id = $this->request->getAttribute('id'); |
| 83 | 83 | $user = $this->adminUserService->getUser($id); |
| 84 | 84 | |
| 85 | - if($this->request->getParsedBody()) { |
|
| 86 | - $user = (object)($this->request->getParsedBody() + (array)$user); |
|
| 85 | + if ($this->request->getParsedBody()) { |
|
| 86 | + $user = (object) ($this->request->getParsedBody() + (array) $user); |
|
| 87 | 87 | $user->admin_user_id = $id; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | try { |
| 100 | 100 | $userId = $this->request->getAttribute('id'); |
| 101 | 101 | $data = $this->request->getParsedBody(); |
| 102 | - $data += (new Request())->getFiles()->toArray(); |
|
| 102 | + $data += (new Request())->getFiles()->toArray(); |
|
| 103 | 103 | |
| 104 | - if($userId) { |
|
| 104 | + if ($userId) { |
|
| 105 | 105 | $this->adminUserService->updateUser($data, $userId); |
| 106 | 106 | } |
| 107 | 107 | else { |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users')); |
| 112 | 112 | } |
| 113 | - catch(FilterException $fe) { |
|
| 113 | + catch (FilterException $fe) { |
|
| 114 | 114 | return $this->edit($fe->getArrayMessages()); |
| 115 | 115 | } |
| 116 | - catch(\Exception $e) { |
|
| 116 | + catch (\Exception $e) { |
|
| 117 | 117 | throw $e; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users')); |
| 128 | 128 | } |
| 129 | - catch(\Exception $e) { |
|
| 129 | + catch (\Exception $e) { |
|
| 130 | 130 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users')); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -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 | |
@@ -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 | /** |
@@ -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\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') |