| Total Complexity | 5 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | trait BackendExporter |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * @var bool |
||
| 32 | */ |
||
| 33 | protected $useExporter = true; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Export driver. |
||
| 37 | * |
||
| 38 | * @var string |
||
| 39 | */ |
||
| 40 | protected $exporter; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Setup grid exporter. |
||
| 44 | * |
||
| 45 | * @return void |
||
| 46 | */ |
||
| 47 | public function setupExporter() |
||
| 48 | { |
||
| 49 | if ($scope = Input::get(Exporter::$queryName)) { |
||
| 50 | if (!$this->useExporter) { |
||
| 51 | // Failed, throw exception |
||
| 52 | throw new NotAcceptableHttpException(trans('backend.export_forbidden')); |
||
| 53 | } |
||
| 54 | |||
| 55 | (new Exporter($this->repository))->resolve($this->exporter)->withScope($scope)->export(); |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Set exporter driver to export. |
||
| 61 | * |
||
| 62 | * @param $exporter |
||
| 63 | * |
||
| 64 | * @return $this |
||
| 65 | */ |
||
| 66 | public function exporter($exporter) |
||
| 67 | { |
||
| 68 | $this->exporter = $exporter; |
||
| 69 | |||
| 70 | return $this; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Get the export url. |
||
| 75 | * |
||
| 76 | * @param int $scope |
||
| 77 | * @param null $args |
||
|
|
|||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | public function exportUrl($scope = 1, $args = null) |
||
| 86 | } |
||
| 87 | } |
||
| 88 |