PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.2.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.2.0
2.2.0 2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 All 43 releases
fluent-boards / app / Http / Controllers / ImportController.php

ImportController.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 2.2.0, at app/Http/Controllers/ImportController.php

50 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Http\Controllers;
4
5 use Exception;
6 use FluentBoards\Framework\Http\Request\Request;
7 use FluentBoards\App\Services\JsonImportService;
8
9 /** Expose administrator-only JSON import endpoints for the free plugin. */
10 class ImportController extends Controller
11 {
12 /** Import a complete uploaded JSON export. */
13 public function importFile(Request $request)
14 {
15 return $this->runImport('importFile', $request);
16 }
17
18 /** Stage one chunk of a JSON export. */
19 public function uploadJsonChunk(Request $request)
20 {
21 return $this->runImport('uploadJsonChunk', $request);
22 }
23
24 /** Initialize or resume a paginated board import. */
25 public function processJsonImport(Request $request)
26 {
27 return $this->runImport('processJsonImport', $request);
28 }
29
30 /** Delegate import work and translate validation failures into API errors. */
31 private function runImport($method, Request $request)
32 {
33 $service = new JsonImportService(function ($source, $data) {
34 return $this->importExternalSource($source, $data);
35 });
36
37 try {
38 return $this->sendSuccess($service->$method($request));
39 } catch (Exception $exception) {
40 return $this->sendError(['message' => $exception->getMessage()], 422);
41 }
42 }
43
44 /** Allow the Pro controller to supply third-party JSON importers. */
45 protected function importExternalSource($source, $importData)
46 {
47 return null;
48 }
49 }
50