@@ -35,22 +35,32 @@ class Save extends \Magento\Backend\App\Action
35
35
*/
36
36
private $ pageFactory ;
37
37
38
+ /**
39
+ * @var \Magento\Cms\Api\PageRepositoryInterface
40
+ */
41
+ private $ pageRepository ;
42
+
38
43
/**
39
44
* @param Action\Context $context
40
45
* @param PostDataProcessor $dataProcessor
41
46
* @param DataPersistorInterface $dataPersistor
42
47
* @param \Magento\Cms\Model\PageFactory $pageFactory
48
+ * @param \Magento\Cms\Api\PageRepositoryInterface $pageRepository
43
49
*/
44
50
public function __construct (
45
51
Action \Context $ context ,
46
52
PostDataProcessor $ dataProcessor ,
47
53
DataPersistorInterface $ dataPersistor ,
48
- \Magento \Cms \Model \PageFactory $ pageFactory = null
54
+ \Magento \Cms \Model \PageFactory $ pageFactory = null ,
55
+ \Magento \Cms \Api \PageRepositoryInterface $ pageRepository = null
49
56
) {
50
57
$ this ->dataProcessor = $ dataProcessor ;
51
58
$ this ->dataPersistor = $ dataPersistor ;
52
59
$ this ->pageFactory = $ pageFactory
53
60
?: \Magento \Framework \App \ObjectManager::getInstance ()->get (\Magento \Cms \Model \PageFactory::class);
61
+ $ this ->pageRepository = $ pageRepository
62
+ ?: \Magento \Framework \App \ObjectManager::getInstance ()
63
+ ->get (\Magento \Cms \Api \PageRepositoryInterface::class);
54
64
55
65
parent ::__construct ($ context );
56
66
}
@@ -102,7 +112,7 @@ public function execute()
102
112
}
103
113
104
114
try {
105
- $ model -> save ();
115
+ $ this -> pageRepository -> save ($ model );
106
116
$ this ->messageManager ->addSuccess (__ ('You saved the page. ' ));
107
117
$ this ->dataPersistor ->clear ('cms_page ' );
108
118
if ($ this ->getRequest ()->getParam ('back ' )) {
0 commit comments