4
4
* Copyright © Magento, Inc. All rights reserved.
5
5
* See COPYING.txt for license details.
6
6
*/
7
+ declare (strict_types=1 );
8
+
7
9
namespace Magento \Cms \Controller \Noroute ;
8
10
11
+ use Magento \Cms \Helper \Page ;
12
+ use Magento \Framework \App \Action \Context ;
13
+ use Magento \Framework \Controller \Result \ForwardFactory ;
14
+ use Magento \Framework \Controller \ResultInterface ;
15
+ use Magento \Framework \Controller \Result \Forward ;
16
+
9
17
/**
10
18
* @SuppressWarnings(PHPMD.AllPurposeAction)
11
19
*/
12
20
class Index extends \Magento \Framework \App \Action \Action
13
21
{
14
22
/**
15
- * @var \Magento\Framework\Controller\Result\ ForwardFactory
23
+ * @var ForwardFactory
16
24
*/
17
- protected $ resultForwardFactory ;
25
+ protected ForwardFactory $ resultForwardFactory ;
18
26
19
27
/**
20
- * @param \Magento\Framework\App\Action\ Context $context
21
- * @param \Magento\Framework\Controller\Result\ ForwardFactory $resultForwardFactory
28
+ * @param Context $context
29
+ * @param ForwardFactory $resultForwardFactory
22
30
*/
23
31
public function __construct (
24
- \ Magento \ Framework \ App \ Action \ Context $ context ,
25
- \ Magento \ Framework \ Controller \ Result \ ForwardFactory $ resultForwardFactory
32
+ Context $ context ,
33
+ ForwardFactory $ resultForwardFactory
26
34
) {
27
35
$ this ->resultForwardFactory = $ resultForwardFactory ;
28
36
parent ::__construct ($ context );
@@ -31,26 +39,27 @@ public function __construct(
31
39
/**
32
40
* Render CMS 404 Not found page
33
41
*
34
- * @return \Magento\Framework\Controller\ ResultInterface
42
+ * @return ResultInterface|Forward
35
43
*/
36
- public function execute ()
44
+ public function execute (): ResultInterface | Forward
37
45
{
38
46
$ pageId = $ this ->_objectManager ->get (
39
47
\Magento \Framework \App \Config \ScopeConfigInterface::class,
40
48
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
41
49
)->getValue (
42
- \ Magento \ Cms \ Helper \ Page::XML_PATH_NO_ROUTE_PAGE ,
50
+ Page::XML_PATH_NO_ROUTE_PAGE ,
43
51
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
44
52
);
45
- /** @var \Magento\Cms\Helper\ Page $pageHelper */
46
- $ pageHelper = $ this ->_objectManager ->get (\ Magento \ Cms \ Helper \ Page::class);
53
+ /** @var Page $pageHelper */
54
+ $ pageHelper = $ this ->_objectManager ->get (Page::class);
47
55
$ resultPage = $ pageHelper ->prepareResultPage ($ this , $ pageId );
48
56
if ($ resultPage ) {
49
57
$ resultPage ->setStatusHeader (404 , '1.1 ' , 'Not Found ' );
50
58
$ resultPage ->setHeader ('Status ' , '404 File not found ' );
59
+ $ resultPage ->setHeader ('Cache-Control ' , 'no-store, no-cache, must-revalidate, max-age=0 ' , true );
51
60
return $ resultPage ;
52
61
} else {
53
- /** @var \Magento\Framework\Controller\Result\ Forward $resultForward */
62
+ /** @var Forward $resultForward */
54
63
$ resultForward = $ this ->resultForwardFactory ->create ();
55
64
$ resultForward ->setController ('index ' );
56
65
$ resultForward ->forward ('defaultNoRoute ' );
0 commit comments