. */ namespace SP\Modules\Api\Controllers; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Services\Api\ApiResponse; use SP\Services\Backup\FileBackupService; use SP\Services\Export\XmlExportService; /** * Class ConfigController * * @package SP\Modules\Api\Controllers */ final class ConfigController extends ControllerBase { /** * backupAction * * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ public function backupAction() { try { $this->setupApi(ActionsInterface::BACKUP_CONFIG); $this->dic->get(FileBackupService::class) ->doBackup(BACKUP_PATH); $this->eventDispatcher->notifyEvent('run.backup.end', new Event($this, EventMessage::factory() ->addDescription(__u('Copia de la aplicación y base de datos realizada correctamente'))) ); $this->returnResponse(new ApiResponse(__u('Proceso de backup finalizado'))); } catch (\Exception $e) { $this->returnResponseException($e); processException($e); } } /** * exportAction * * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ public function exportAction() { try { $this->setupApi(ActionsInterface::EXPORT_CONFIG); $password = $this->apiService->getParamString('password'); $this->eventDispatcher->notifyEvent('run.export.start', new Event($this, EventMessage::factory() ->addDescription(__u('Exportación de sysPass en XML'))) ); $this->dic->get(XmlExportService::class) ->doExport(BACKUP_PATH, $password); $this->eventDispatcher->notifyEvent('run.export.end', new Event($this, EventMessage::factory() ->addDescription(__u('Proceso de exportación finalizado'))) ); $this->returnResponse(new ApiResponse(__u('Proceso de exportación finalizado'))); } catch (\Exception $e) { $this->returnResponseException($e); processException($e); } } }