AppsController.php
1 month ago
CollaborationCommentController.php
1 month ago
CollaborationController.php
1 week ago
CollectionController.php
1 week ago
CollectionItemController.php
1 month ago
EditorController.php
1 week ago
FormController.php
1 week ago
GlobalDataController.php
2 weeks ago
MediaController.php
1 month ago
PageController.php
1 week ago
PageSettingsController.php
1 week ago
PostController.php
1 week ago
UserController.php
1 week ago
FormController.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Http\Controllers\Api; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use Kirki\Framework\Http\Request; |
| 8 | use Kirki\App\Services\FormSubmissionService; |
| 9 | use function Kirki\Framework\response; |
| 10 | |
| 11 | /** |
| 12 | * Handles front-end form submissions. |
| 13 | * |
| 14 | * Route: POST /kirki/v1/frontend/form (public). |
| 15 | */ |
| 16 | class FormController |
| 17 | { |
| 18 | /** |
| 19 | * @var FormSubmissionService |
| 20 | */ |
| 21 | protected $service; |
| 22 | |
| 23 | /** |
| 24 | * @param FormSubmissionService $service |
| 25 | */ |
| 26 | public function __construct(FormSubmissionService $service) |
| 27 | { |
| 28 | $this->service = $service; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Store a form submission. |
| 33 | * |
| 34 | * @param Request $request The submission request. |
| 35 | * @return \Kirki\Framework\Http\JsonResponse |
| 36 | */ |
| 37 | public function store(Request $request) |
| 38 | { |
| 39 | $result = $this->service->handle($request->all(), $request->all_files()); |
| 40 | |
| 41 | return response()->json([ |
| 42 | 'data' => $result, |
| 43 | 'message' => __('Form submitted successfully.', 'kirki'), |
| 44 | ]); |
| 45 | } |
| 46 | } |
| 47 |