| @@ 43-63 (lines=21) @@ | ||
| 40 | * |
|
| 41 | * @return Form |
|
| 42 | */ |
|
| 43 | protected function resolveForm(Request $request) |
|
| 44 | { |
|
| 45 | if (!$request->has('_form_')) { |
|
| 46 | throw new Exception('Invalid form request.'); |
|
| 47 | } |
|
| 48 | ||
| 49 | $formClass = $request->get('_form_'); |
|
| 50 | ||
| 51 | if (!class_exists($formClass)) { |
|
| 52 | throw new Exception("Form [{$formClass}] does not exist."); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** @var Form $form */ |
|
| 56 | $form = app($formClass); |
|
| 57 | ||
| 58 | if (!method_exists($form, 'handle')) { |
|
| 59 | throw new Exception("Form method {$formClass}::handle() does not exist."); |
|
| 60 | } |
|
| 61 | ||
| 62 | return $form; |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * @param Request $request |
|
| @@ 110-130 (lines=21) @@ | ||
| 107 | * |
|
| 108 | * @return Action |
|
| 109 | */ |
|
| 110 | protected function resolveActionInstance(Request $request) |
|
| 111 | { |
|
| 112 | if (!$request->has('_action')) { |
|
| 113 | throw new Exception('Invalid action request.'); |
|
| 114 | } |
|
| 115 | ||
| 116 | $actionClass = str_replace('_', '\\', $request->get('_action')); |
|
| 117 | ||
| 118 | if (!class_exists($actionClass)) { |
|
| 119 | throw new Exception("Form [{$actionClass}] does not exist."); |
|
| 120 | } |
|
| 121 | ||
| 122 | /** @var GridAction $form */ |
|
| 123 | $action = app($actionClass); |
|
| 124 | ||
| 125 | if (!method_exists($action, 'handle')) { |
|
| 126 | throw new Exception("Action method {$actionClass}::handle() does not exist."); |
|
| 127 | } |
|
| 128 | ||
| 129 | return $action; |
|
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * @param Request $request |
|