InvalidRequestException.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Framework\App\Request;
  8. use Magento\Framework\App\ResponseInterface;
  9. use Magento\Framework\Controller\ResultInterface;
  10. use Magento\Framework\Exception\NotFoundException;
  11. use Magento\Framework\Exception\RuntimeException;
  12. use Magento\Framework\Phrase;
  13. /**
  14. * Received request is invalid.
  15. */
  16. class InvalidRequestException extends RuntimeException
  17. {
  18. /**
  19. * @var ResponseInterface|ResultInterface
  20. */
  21. private $replaceResult;
  22. /**
  23. * @var Phrase[]|null
  24. */
  25. private $messages;
  26. /**
  27. * @param ResponseInterface|ResultInterface|NotFoundException $replaceResult
  28. * Use this result instead of calling an action instance,
  29. * if NotFoundException is given the the default 404 mechanism will be triggered.
  30. * @param Phrase[]|null $messages Messages to show to client
  31. * as error messages.
  32. */
  33. public function __construct($replaceResult, ?array $messages = null)
  34. {
  35. parent::__construct(new Phrase('Invalid request received'));
  36. $this->replaceResult = $replaceResult;
  37. $this->messages = $messages;
  38. }
  39. /**
  40. * @return ResponseInterface|ResultInterface|NotFoundException
  41. */
  42. public function getReplaceResult()
  43. {
  44. return $this->replaceResult;
  45. }
  46. /**
  47. * @return Phrase[]|null
  48. */
  49. public function getMessages(): ?array
  50. {
  51. return $this->messages;
  52. }
  53. }