[TASK] Deprecate extbase StopActionException
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Exception / StopActionException.php
1 <?php
2
3 declare(strict_types=1);
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 namespace TYPO3\CMS\Extbase\Mvc\Exception;
19
20 use Psr\Http\Message\ResponseInterface;
21 use TYPO3\CMS\Core\Http\Response;
22 use TYPO3\CMS\Extbase\Mvc\Exception;
23
24 /**
25 * This exception is thrown by a controller to stop the execution of the current
26 * action and return the control to the dispatcher. The dispatcher catches this
27 * exception and - depending on the "dispatched" status of the request - either
28 * continues dispatching the request or returns control to the request handler.
29 *
30 * See the Action Controller's forward() and redirectToUri() methods for more information.
31 *
32 * @deprecated since v11, will be removed in v12. This action shouldn't be thrown anymore:
33 * Actions that extbase-internally forward to another action should RETURN Extbase\Http\ForwardResponse
34 * instead. Actions that initiate a client redirect should RETURN a Core\Http\RedirectResponse instead.
35 */
36 class StopActionException extends Exception
37 {
38 /**
39 * @var ResponseInterface
40 */
41 private $response;
42
43 public function __construct($message = '', $code = 0, \Throwable $previous = null, ResponseInterface $response = null)
44 {
45 // @deprecated since v11, will be removed in v12. Can not trigger_error() here since
46 // extbase ActionController still has to use this exception for b/w compatibility.
47 // See the usages of this exception when dropping in v12.
48 $this->response = $response ?? new Response();
49 parent::__construct($message, $code, $previous);
50 }
51
52 public function getResponse(): ResponseInterface
53 {
54 return $this->response;
55 }
56 }