Raw.php 890 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Controller\Result;
  7. use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
  8. use Magento\Framework\Controller\AbstractResult;
  9. /**
  10. * A result that contains raw response - may be good for passing through files,
  11. * returning result of downloads or some other binary contents
  12. */
  13. class Raw extends AbstractResult
  14. {
  15. /**
  16. * @var string
  17. */
  18. protected $contents;
  19. /**
  20. * @param string $contents
  21. * @return $this
  22. */
  23. public function setContents($contents)
  24. {
  25. $this->contents = $contents;
  26. return $this;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function render(HttpResponseInterface $response)
  32. {
  33. $response->setBody($this->contents);
  34. return $this;
  35. }
  36. }