@@ -2,10 +2,7 @@ |
||
2 | 2 | use Silex\Application; |
3 | 3 | use Symfony\Component\HttpFoundation\Request; |
4 | 4 | use Symfony\Component\HttpFoundation\Response; |
5 | -use Symfony\Component\HttpFoundation\ParameterBag; |
|
6 | 5 | use PhpDraft\Domain\Models\PhpDraftResponse; |
7 | -use Symfony\Component\Debug\ErrorHandler; |
|
8 | -use Symfony\Component\Debug\ExceptionHandler; |
|
9 | 6 | |
10 | 7 | if (!$app instanceof Silex\Application) { |
11 | 8 | throw new Exception('Invalid application setup.'); |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | throw new Exception('Invalid application setup.'); |
12 | 12 | } |
13 | 13 | |
14 | -$app->error(function (\Exception $e, $code) use($app) { |
|
14 | +$app->error(function(\Exception $e, $code) use($app) { |
|
15 | 15 | return $app->json(array("error" => $e->getMessage()), Response::HTTP_INTERNAL_SERVER_ERROR); |
16 | 16 | }); |
17 | 17 | |
18 | 18 | //If we get application/json, decode the data so controllers can use it |
19 | -$app->before(function (Request $request) { |
|
19 | +$app->before(function(Request $request) { |
|
20 | 20 | if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) { |
21 | 21 | $data = json_decode($request->getContent(), true); |
22 | 22 | $request->request->replace(is_array($data) ? $data : array()); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $viewable = $app['phpdraft.DraftValidator']->IsDraftViewableForUser($draft_id, $request); |
31 | 31 | |
32 | - if(!$viewable) { |
|
32 | + if (!$viewable) { |
|
33 | 33 | $response = new PhpDraftResponse(false, array()); |
34 | 34 | $response->errors[] = "Draft marked as private."; |
35 | 35 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $setting_up = $app['phpdraft.DraftValidator']->IsDraftSettingUpOrInProgress($draft); |
45 | 45 | |
46 | - if(!$setting_up->success) { |
|
46 | + if (!$setting_up->success) { |
|
47 | 47 | return $app->json(array($setting_up), $setting_up->responseType()); |
48 | 48 | } |
49 | 49 | }; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $in_progress = $app['phpdraft.DraftValidator']->IsDraftInProgress($draft); |
56 | 56 | |
57 | - if(!$in_progress->success) { |
|
57 | + if (!$in_progress->success) { |
|
58 | 58 | return $app->json(array($in_progress), $in_progress->responseType()); |
59 | 59 | } |
60 | 60 | }; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | $in_progress = $app['phpdraft.DraftValidator']->IsDraftInProgressOrComplete($draft); |
67 | 67 | |
68 | - if(!$in_progress->success) { |
|
68 | + if (!$in_progress->success) { |
|
69 | 69 | return $app->json(array($in_progress), $in_progress->responseType()); |
70 | 70 | } |
71 | 71 | }; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $grace_period = $app['phpdraft.DraftValidator']->IsDraftInProgressOrCompletedInLessThanTen($draft); |
79 | 79 | |
80 | - if(!$grace_period->success) { |
|
80 | + if (!$grace_period->success) { |
|
81 | 81 | return $app->json(array($grace_period), $grace_period->responseType()); |
82 | 82 | } |
83 | 83 | }; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | $completed = $app['phpdraft.DraftValidator']->IsDraftComplete($draft); |
90 | 90 | |
91 | - if(!$completed->success) { |
|
91 | + if (!$completed->success) { |
|
92 | 92 | return $app->json(array($completed), $completed->responseType()); |
93 | 93 | } |
94 | 94 | }; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $editable = $app['phpdraft.DraftValidator']->IsDraftEditableForUser($draft, $current_user); |
103 | 103 | |
104 | - if(!$editable) { |
|
104 | + if (!$editable) { |
|
105 | 105 | $response = new PhpDraft\Domain\Models\PhpDraftResponse(false, array()); |
106 | 106 | $response->errors[] = "You do not have permission to this draft."; |
107 | 107 |
@@ -1,9 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use Symfony\Component\DependencyInjection\Definition; |
|
4 | -use Symfony\Component\DependencyInjection\Reference; |
|
5 | 3 | use PhpDraft\Config\Security\UserProvider; |
6 | -use PhpDraft\Config\Security\AuthenticationEntryPoint; |
|
7 | 4 | |
8 | 5 | if (!$app instanceof Silex\Application) { |
9 | 6 | throw new Exception('Invalid application setup.'); |
@@ -9,7 +9,7 @@ |
||
9 | 9 | throw new Exception('Invalid application setup.'); |
10 | 10 | } |
11 | 11 | |
12 | -$app['users'] = function () use ($app) { |
|
12 | +$app['users'] = function() use ($app) { |
|
13 | 13 | return new UserProvider($app); |
14 | 14 | }; |
15 | 15 |
@@ -3,10 +3,7 @@ |
||
3 | 3 | namespace PhpDraft\Controllers\Admin; |
4 | 4 | |
5 | 5 | use \Silex\Application; |
6 | -use Symfony\Component\HttpFoundation\Response; |
|
7 | 6 | use Symfony\Component\HttpFoundation\Request; |
8 | -use PhpDraft\Domain\Models\PhpDraftResponse; |
|
9 | -use PhpDraft\Domain\Entities\Draft; |
|
10 | 7 | |
11 | 8 | class DraftStatsController |
12 | 9 | { |
@@ -5,8 +5,6 @@ |
||
5 | 5 | use \Silex\Application; |
6 | 6 | use Symfony\Component\HttpFoundation\Response; |
7 | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | -use PhpDraft\Domain\Models\PhpDraftResponse; |
|
9 | -use PhpDraft\Domain\Entities\Draft; |
|
10 | 8 | |
11 | 9 | class ProPlayerController |
12 | 10 | { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | $validity = $app['phpdraft.ProPlayerValidator']->IsUploadSportValid($sport, $file); |
24 | 24 | |
25 | - if(!$validity->success) { |
|
25 | + if (!$validity->success) { |
|
26 | 26 | return $app->json($validity, $validity->responseType()); |
27 | 27 | } |
28 | 28 |
@@ -3,10 +3,8 @@ |
||
3 | 3 | namespace PhpDraft\Controllers\Admin; |
4 | 4 | |
5 | 5 | use \Silex\Application; |
6 | -use Symfony\Component\HttpFoundation\Response; |
|
7 | 6 | use Symfony\Component\HttpFoundation\Request; |
8 | 7 | use PhpDraft\Domain\Models\PhpDraftResponse; |
9 | -use PhpDraft\Domain\Entities\Draft; |
|
10 | 8 | |
11 | 9 | class UserController |
12 | 10 | { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $validity = $app['phpdraft.LoginUserValidator']->IsAdminUserUpdateValid($user); |
32 | 32 | |
33 | - if(!$validity->success) { |
|
33 | + if (!$validity->success) { |
|
34 | 34 | return $app->json($validity, $validity->responseType()); |
35 | 35 | } |
36 | 36 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $user_id = $request->get('user_id'); |
46 | 46 | $user = $app['phpdraft.LoginUserRepository']->LoadById($user_id); |
47 | 47 | |
48 | - if($app['phpdraft.LoginUserService']->CurrentUserIsAdmin($user)) { |
|
48 | + if ($app['phpdraft.LoginUserService']->CurrentUserIsAdmin($user)) { |
|
49 | 49 | $response = new PhpDraftResponse(false, array()); |
50 | 50 | $response->errors[] = "Unable to delete user - user is admin."; |
51 | 51 |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use \Silex\Application; |
6 | 6 | use Symfony\Component\HttpFoundation\Response; |
7 | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | -use PhpDraft\Domain\Models\PhpDraftResponse; |
|
9 | 8 | use PhpDraft\Domain\Entities\Draft; |
10 | 9 | |
11 | 10 | class DraftController |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | |
43 | 43 | $validity = $app['phpdraft.DraftValidator']->IsDraftValidForCreateAndUpdate($draft); |
44 | 44 | |
45 | - if(!$validity->success) { |
|
45 | + if (!$validity->success) { |
|
46 | 46 | return $app->json($validity, Response::HTTP_BAD_REQUEST); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $createPositionsModel = null; |
50 | 50 | |
51 | - if($draft->using_depth_charts == 1) { |
|
51 | + if ($draft->using_depth_charts == 1) { |
|
52 | 52 | $createPositionsModel = $this->_BuildDepthChartPositionModel($request); |
53 | 53 | |
54 | 54 | $positionValidity = $app['phpdraft.DepthChartPositionValidator']->AreDepthChartPositionsValid($createPositionsModel); |
55 | 55 | |
56 | - if(!$positionValidity->success) { |
|
56 | + if (!$positionValidity->success) { |
|
57 | 57 | return $app->json($positionValidity, Response::HTTP_BAD_REQUEST); |
58 | 58 | } |
59 | 59 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | |
91 | 91 | $validity = $app['phpdraft.DraftValidator']->IsDraftValidForCreateAndUpdate($draft); |
92 | 92 | |
93 | - if(!$validity->success) { |
|
93 | + if (!$validity->success) { |
|
94 | 94 | return $app->json($validity, Response::HTTP_BAD_REQUEST); |
95 | 95 | } |
96 | 96 | |
97 | 97 | $createPositionsModel = null; |
98 | 98 | |
99 | - if($draft->using_depth_charts == 1) { |
|
99 | + if ($draft->using_depth_charts == 1) { |
|
100 | 100 | $createPositionsModel = $this->_BuildDepthChartPositionModel($request); |
101 | 101 | |
102 | 102 | $positionValidity = $app['phpdraft.DepthChartPositionValidator']->AreDepthChartPositionsValid($createPositionsModel); |
103 | 103 | |
104 | - if(!$positionValidity->success) { |
|
104 | + if (!$positionValidity->success) { |
|
105 | 105 | return $app->json($positionValidity, Response::HTTP_BAD_REQUEST); |
106 | 106 | } |
107 | 107 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $validity = $app['phpdraft.DraftValidator']->IsDraftStatusValid($draft, $oldStatus); |
122 | 122 | |
123 | - if(!$validity->success) { |
|
123 | + if (!$validity->success) { |
|
124 | 124 | return $app->json($validity, Response::HTTP_BAD_REQUEST); |
125 | 125 | } |
126 | 126 | |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | $createModel = new \PhpDraft\Domain\Models\RoundTimeCreateModel(); |
155 | 155 | $createModel->isRoundTimesEnabled = (bool)$request->get('isRoundTimesEnabled'); |
156 | 156 | |
157 | - if($createModel->isRoundTimesEnabled) { |
|
157 | + if ($createModel->isRoundTimesEnabled) { |
|
158 | 158 | $roundTimesJson = $request->get('roundTimes'); |
159 | 159 | |
160 | - foreach($roundTimesJson as $roundTimeRequest) { |
|
160 | + foreach ($roundTimesJson as $roundTimeRequest) { |
|
161 | 161 | $newRoundTime = new \PhpDraft\Domain\Entities\RoundTime(); |
162 | 162 | $newRoundTime->draft_id = $draftId; |
163 | 163 | $newRoundTime->is_static_time = $roundTimeRequest['is_static_time'] == "true" ? 1 : 0; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | $validity = $app['phpdraft.RoundTimeValidator']->AreRoundTimesValid($createModel); |
172 | 172 | |
173 | - if(!$validity->success) { |
|
173 | + if (!$validity->success) { |
|
174 | 174 | return $app->json($validity, Response::HTTP_BAD_REQUEST); |
175 | 175 | } |
176 | 176 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $depthChartPositionJson = $request->get('depthChartPositions'); |
188 | 188 | $display_order = 0; |
189 | 189 | |
190 | - foreach($depthChartPositionJson as $depthChartPositionRequest) { |
|
190 | + foreach ($depthChartPositionJson as $depthChartPositionRequest) { |
|
191 | 191 | $depthChartPosition = new \PhpDraft\Domain\Entities\DepthChartPosition(); |
192 | 192 | $depthChartPosition->draft_id = $draftId; |
193 | 193 | $depthChartPosition->position = $depthChartPositionRequest['position']; |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use \Silex\Application; |
6 | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | 7 | use Symfony\Component\HttpFoundation\Response; |
8 | -use PhpDraft\Domain\Entities\ProPlayer; |
|
9 | 8 | use PhpDraft\Domain\Models\PhpDraftResponse; |
10 | 9 | |
11 | 10 | class PickController { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $pick->last_name = $request->get('last_name'); |
31 | 31 | $pick->team = $request->get('team'); |
32 | 32 | $pick->position = $request->get('position'); |
33 | - } catch(\Exception $e) { |
|
33 | + } catch (\Exception $e) { |
|
34 | 34 | $response = new PhpDraftResponse(false, array()); |
35 | 35 | $response->errors[] = "Unable to add pick #$pick_id"; |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $validity = $app['phpdraft.PickValidator']->IsPickValidForAdd($draft, $pick); |
41 | 41 | |
42 | - if(!$validity->success) { |
|
42 | + if (!$validity->success) { |
|
43 | 43 | return $app->json($validity, $validity->responseType()); |
44 | 44 | } |
45 | 45 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $pick->last_name = $request->get('last_name'); |
61 | 61 | $pick->team = $request->get('team'); |
62 | 62 | $pick->position = $request->get('position'); |
63 | - } catch(\Exception $e) { |
|
63 | + } catch (\Exception $e) { |
|
64 | 64 | $response = new PhpDraftResponse(false, array()); |
65 | 65 | $response->errors[] = "Unable to edit pick #$pick_id"; |
66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $validity = $app['phpdraft.PickValidator']->IsPickValidForUpdate($draft, $pick); |
71 | 71 | |
72 | - if(!$validity->success) { |
|
72 | + if (!$validity->success) { |
|
73 | 73 | return $app->json($validity, $validity->responseType()); |
74 | 74 | } |
75 | 75 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $response->draft_rounds = $draft->draft_rounds; |
100 | 100 | $response->last_5_picks = $app['phpdraft.PickRepository']->LoadLastPicks($draft_id, 5); |
101 | 101 | $response->success = true; |
102 | - } catch(\Exception $e) { |
|
102 | + } catch (\Exception $e) { |
|
103 | 103 | $response->success = false; |
104 | 104 | $response->errors[] = "Unable to load last 5 picks."; |
105 | 105 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $response->round = $round; |
118 | 118 | $response->round_picks = $app['phpdraft.PickRepository']->LoadRoundPicks($draft, $round, false, true); |
119 | 119 | $response->success = true; |
120 | - } catch(\Exception $e) { |
|
120 | + } catch (\Exception $e) { |
|
121 | 121 | $response->success = false; |
122 | 122 | $response->errors[] = "Unable to load round #$round's picks"; |
123 | 123 | } |
@@ -4,8 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use \Silex\Application; |
6 | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | -use Symfony\Component\HttpFoundation\Response; |
|
8 | -use PhpDraft\Domain\Entities\ProPlayer; |
|
9 | 7 | use PhpDraft\Domain\Models\PhpDraftResponse; |
10 | 8 | |
11 | 9 | class ProPlayerController { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | $response = new PhpDraftResponse(); |
28 | 28 | |
29 | - if(count($searchTerm) > 0) { |
|
29 | + if (count($searchTerm) > 0) { |
|
30 | 30 | $response = $app['phpdraft.ProPlayerService']->SearchPlayers($league, $searchTerm); |
31 | 31 | } else { |
32 | 32 | $response = $app['phpdraft.ProPlayerService']->SearchPlayersManual($league, $first, $last, $team, $position); |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use Symfony\Component\HttpFoundation\Response; |
8 | 8 | use PhpDraft\Domain\Entities\Trade; |
9 | 9 | use PhpDraft\Domain\Entities\TradeAsset; |
10 | -use PhpDraft\Domain\Entities\Manager; |
|
11 | 10 | use PhpDraft\Domain\Models\PhpDraftResponse; |
12 | 11 | |
13 | 12 | class TradeController { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | try { |
21 | 21 | $manager = $app['phpdraft.ManagerRepository']->Load($managerId); |
22 | - } catch(\Exception $e) { |
|
22 | + } catch (\Exception $e) { |
|
23 | 23 | $response = new PhpDraftResponse(false, array()); |
24 | 24 | $response->errors[] = "Unable to load manager #$managerId"; |
25 | 25 | return $app->json($response, Response::HTTP_BAD_REQUEST); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | $validity = $app['phpdraft.TradeValidator']->IsManagerValidForAssetRetrieval($draft, $manager); |
29 | 29 | |
30 | - if(!$validity->success) { |
|
30 | + if (!$validity->success) { |
|
31 | 31 | return $app->json($validity, Response::HTTP_BAD_REQUEST); |
32 | 32 | } |
33 | 33 | |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | $newTrade->manager1 = $app['phpdraft.ManagerRepository']->Load($newTrade->manager1_id); |
54 | 54 | $newTrade->manager2 = $app['phpdraft.ManagerRepository']->Load($newTrade->manager2_id); |
55 | 55 | |
56 | - foreach($assets_json as $asset_id) { |
|
56 | + foreach ($assets_json as $asset_id) { |
|
57 | 57 | $newTradeAsset = new TradeAsset(); |
58 | 58 | $newTradeAsset->player = $app['phpdraft.PickRepository']->Load($asset_id); |
59 | 59 | $newTradeAsset->was_drafted = $app['phpdraft.PickService']->PickHasBeenSelected($newTradeAsset->player); |
60 | 60 | |
61 | - if($newTradeAsset->player->manager_id == $newTrade->manager1_id) { |
|
61 | + if ($newTradeAsset->player->manager_id == $newTrade->manager1_id) { |
|
62 | 62 | $newTradeAsset->oldmanager_id = $newTrade->manager1_id; |
63 | 63 | $newTradeAsset->newmanager_id = $newTrade->manager2_id; |
64 | 64 | $newTradeAsset->oldmanager = $newTrade->manager1; |
65 | 65 | $newTradeAsset->newmanager = $newTrade->manager2; |
66 | - } else if($newTradeAsset->player->manager_id == $newTrade->manager2_id) { |
|
66 | + } else if ($newTradeAsset->player->manager_id == $newTrade->manager2_id) { |
|
67 | 67 | $newTradeAsset->oldmanager_id = $newTrade->manager2_id; |
68 | 68 | $newTradeAsset->newmanager_id = $newTrade->manager1_id; |
69 | 69 | $newTradeAsset->oldmanager = $newTrade->manager2; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $newTrade->trade_assets[] = $newTradeAsset; |
76 | 76 | } |
77 | - } catch(\Exception $e) { |
|
77 | + } catch (\Exception $e) { |
|
78 | 78 | $response = new PhpDraftResponse(false, array()); |
79 | 79 | $message = $e->getMessage(); |
80 | 80 | $response->errors[] = "Unable to build trade: $message"; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | $validity = $app['phpdraft.TradeValidator']->IsTradeValid($draft, $newTrade); |
86 | 86 | |
87 | - if(!$validity->success) { |
|
87 | + if (!$validity->success) { |
|
88 | 88 | return $app->json($validity, Response::HTTP_BAD_REQUEST); |
89 | 89 | } |
90 | 90 |