FeaturesIntegrations
1 month ago
ExportDataTransferCommand.php
3 weeks ago
ExportDataTransferCommandHandler.php
3 weeks ago
GetSettingsCommand.php
1 year ago
GetSettingsCommandHandler.php
1 month ago
ProcessImportDataTransferCommand.php
3 weeks ago
ProcessImportDataTransferCommandHandler.php
3 weeks ago
StartImportDataTransferCommand.php
3 weeks ago
StartImportDataTransferCommandHandler.php
3 weeks ago
UpdateSettingsCategoriesCommand.php
7 months ago
UpdateSettingsCategoriesCommandHandler.php
1 month ago
UpdateSettingsCommand.php
1 year ago
UpdateSettingsCommandHandler.php
1 month ago
ExportDataTransferCommandHandler.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Commands\Settings; |
| 4 | |
| 5 | use AmeliaBooking\Application\Commands\CommandHandler; |
| 6 | use AmeliaBooking\Application\Commands\CommandResult; |
| 7 | use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException; |
| 8 | use AmeliaBooking\Domain\Entity\Entities; |
| 9 | use AmeliaBooking\Infrastructure\Services\DataTransfer\DataTransferService; |
| 10 | |
| 11 | class ExportDataTransferCommandHandler extends CommandHandler |
| 12 | { |
| 13 | public function handle(ExportDataTransferCommand $command): CommandResult |
| 14 | { |
| 15 | if (!$command->getPermissionService()->currentUserCanWrite(Entities::SETTINGS)) { |
| 16 | throw new AccessDeniedException('You are not allowed to export Amelia settings and data.'); |
| 17 | } |
| 18 | |
| 19 | /** @var DataTransferService $dataTransferService */ |
| 20 | $dataTransferService = $this->container->get('infrastructure.dataTransfer.service'); |
| 21 | |
| 22 | $result = new CommandResult(); |
| 23 | $result->setResult(CommandResult::RESULT_SUCCESS); |
| 24 | $result->setMessage('Successfully exported Amelia data.'); |
| 25 | $result->setData($dataTransferService->exportArchive()); |
| 26 | |
| 27 | return $result; |
| 28 | } |
| 29 | } |
| 30 |