DataDownloadResponse.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Georg Ehrke <georg@owncloud.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\AppFramework\Http;
  24. /**
  25. * Class DataDownloadResponse
  26. *
  27. * @package OCP\AppFramework\Http
  28. * @since 8.0.0
  29. */
  30. class DataDownloadResponse extends DownloadResponse {
  31. /**
  32. * @var string
  33. */
  34. private $data;
  35. /**
  36. * Creates a response that prompts the user to download the text
  37. * @param string $data text to be downloaded
  38. * @param string $filename the name that the downloaded file should have
  39. * @param string $contentType the mimetype that the downloaded file should have
  40. * @since 8.0.0
  41. */
  42. public function __construct($data, $filename, $contentType) {
  43. $this->data = $data;
  44. parent::__construct($filename, $contentType);
  45. }
  46. /**
  47. * @param string $data
  48. * @since 8.0.0
  49. */
  50. public function setData($data) {
  51. $this->data = $data;
  52. }
  53. /**
  54. * @return string
  55. * @since 8.0.0
  56. */
  57. public function render() {
  58. return $this->data;
  59. }
  60. }