7
7
8
8
namespace Firegento \ContentProvisioning \Controller \Adminhtml \Page ;
9
9
10
+ use Exception ;
10
11
use Firegento \ContentProvisioning \Model \Command \ApplyPageEntry ;
11
12
use Firegento \ContentProvisioning \Model \Query \GetPageEntryByPage ;
12
13
use Magento \Backend \App \Action ;
14
+ use Magento \Backend \Model \View \Result \Redirect ;
15
+ use Magento \Cms \Api \Data \PageInterface ;
16
+ use Magento \Cms \Api \PageRepositoryInterface ;
13
17
use Magento \Cms \Controller \Adminhtml \Page \PostDataProcessor ;
14
18
use Magento \Cms \Model \Page ;
19
+ use Magento \Cms \Model \PageFactory ;
15
20
use Magento \Framework \App \Action \HttpPostActionInterface ;
21
+ use Magento \Framework \App \ObjectManager ;
16
22
use Magento \Framework \App \Request \DataPersistorInterface ;
23
+ use Magento \Framework \Controller \ResultInterface ;
17
24
use Magento \Framework \Exception \LocalizedException ;
18
25
19
26
/**
20
27
* Save CMS page action.
21
28
*/
22
- class Save extends \ Magento \ Backend \ App \ Action implements HttpPostActionInterface
29
+ class Save extends Action implements HttpPostActionInterface
23
30
{
24
31
/**
25
32
* Authorization level of a basic admin session
@@ -39,12 +46,12 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
39
46
protected $ dataPersistor ;
40
47
41
48
/**
42
- * @var \Magento\Cms\Model\ PageFactory
49
+ * @var PageFactory
43
50
*/
44
51
private $ pageFactory ;
45
52
46
53
/**
47
- * @var \Magento\Cms\Api\ PageRepositoryInterface
54
+ * @var PageRepositoryInterface
48
55
*/
49
56
private $ pageRepository ;
50
57
@@ -62,25 +69,25 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
62
69
* @param Action\Context $context
63
70
* @param PostDataProcessor $dataProcessor
64
71
* @param DataPersistorInterface $dataPersistor
65
- * @param \Magento\Cms\Model\ PageFactory|null $pageFactory
66
- * @param \Magento\Cms\Api\ PageRepositoryInterface|null $pageRepository
72
+ * @param PageFactory|null $pageFactory
73
+ * @param PageRepositoryInterface|null $pageRepository
67
74
*/
68
75
public function __construct (
69
76
Action \Context $ context ,
70
77
PostDataProcessor $ dataProcessor ,
71
78
DataPersistorInterface $ dataPersistor ,
72
79
GetPageEntryByPage $ getPageEntryByPage ,
73
80
ApplyPageEntry $ applyPageEntry ,
74
- \ Magento \ Cms \ Model \ PageFactory $ pageFactory = null ,
75
- \ Magento \ Cms \ Api \ PageRepositoryInterface $ pageRepository = null
81
+ PageFactory $ pageFactory = null ,
82
+ PageRepositoryInterface $ pageRepository = null
76
83
) {
77
84
$ this ->dataProcessor = $ dataProcessor ;
78
85
$ this ->dataPersistor = $ dataPersistor ;
79
86
$ this ->pageFactory = $ pageFactory
80
- ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()->get (\ Magento \ Cms \ Model \ PageFactory::class);
87
+ ?: ObjectManager::getInstance ()->get (PageFactory::class);
81
88
$ this ->pageRepository = $ pageRepository
82
- ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()
83
- ->get (\ Magento \ Cms \ Api \ PageRepositoryInterface::class);
89
+ ?: ObjectManager::getInstance ()
90
+ ->get (PageRepositoryInterface::class);
84
91
parent ::__construct ($ context );
85
92
$ this ->getPageEntryByPage = $ getPageEntryByPage ;
86
93
$ this ->applyPageEntry = $ applyPageEntry ;
@@ -90,12 +97,12 @@ public function __construct(
90
97
* Save action
91
98
*
92
99
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
93
- * @return \Magento\Framework\Controller\ ResultInterface
100
+ * @return ResultInterface
94
101
*/
95
102
public function execute ()
96
103
{
97
104
$ data = $ this ->getRequest ()->getPostValue ();
98
- /** @var \Magento\Backend\Model\View\Result\ Redirect $resultRedirect */
105
+ /** @var Redirect $resultRedirect */
99
106
$ resultRedirect = $ this ->resultRedirectFactory ->create ();
100
107
if ($ data ) {
101
108
$ data = $ this ->dataProcessor ->filter ($ data );
@@ -106,7 +113,7 @@ public function execute()
106
113
$ data ['page_id ' ] = null ;
107
114
}
108
115
109
- /** @var \Magento\Cms\Model\ Page $model */
116
+ /** @var Page $model */
110
117
$ model = $ this ->pageFactory ->create ();
111
118
112
119
$ id = $ this ->getRequest ()->getParam ('page_id ' );
@@ -136,7 +143,7 @@ public function execute()
136
143
return $ this ->processResultRedirect ($ model , $ resultRedirect , $ data );
137
144
} catch (LocalizedException $ e ) {
138
145
$ this ->messageManager ->addExceptionMessage ($ e ->getPrevious () ?: $ e );
139
- } catch (\ Exception $ e ) {
146
+ } catch (Exception $ e ) {
140
147
$ this ->messageManager ->addExceptionMessage ($ e , __ ('Something went wrong while saving the page. ' ));
141
148
}
142
149
@@ -149,10 +156,10 @@ public function execute()
149
156
/**
150
157
* Process result redirect
151
158
*
152
- * @param \Magento\Cms\Api\Data\ PageInterface $model
153
- * @param \Magento\Backend\Model\View\Result\ Redirect $resultRedirect
159
+ * @param PageInterface $model
160
+ * @param Redirect $resultRedirect
154
161
* @param array $data
155
- * @return \Magento\Backend\Model\View\Result\ Redirect
162
+ * @return Redirect
156
163
* @throws LocalizedException
157
164
*/
158
165
private function processResultRedirect ($ model , $ resultRedirect , $ data )
0 commit comments