Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Form / EnforcedResponseException.php
1 <?php
2
3 namespace Drupal\Core\Form;
4
5 use Symfony\Component\HttpFoundation\Response;
6
7 /**
8  * Custom exception to break out of the main request and enforce a response.
9  */
10 class EnforcedResponseException extends \Exception {
11
12   /**
13    * The response to be enforced.
14    *
15    * @var \Symfony\Component\HttpFoundation\Response
16    */
17   protected $response;
18
19   /**
20    * Constructs a new enforced response exception.
21    *
22    * @param \Symfony\Component\HttpFoundation\Response $response
23    *   The response to be enforced.
24    * @param string $message
25    *   (optional) The exception message.
26    * @param int $code
27    *   (optional) A user defined exception code.
28    * @param \Exception $previous
29    *   (optional) The previous exception for nested exceptions
30    */
31   public function __construct(Response $response, $message = "", $code = 0, \Exception $previous = NULL) {
32     parent::__construct($message, $code, $previous);
33
34     $this->response = $response;
35   }
36
37   /**
38    * Return the response to be enforced.
39    *
40    * @returns \Symfony\Component\HttpFoundation\Response $response
41    *   The response to be enforced.
42    */
43   public function getResponse() {
44     return $this->response;
45   }
46
47 }