77
88namespace Firegento \ContentProvisioning \Controller \Adminhtml \Page ;
99
10+ use Exception ;
1011use Firegento \ContentProvisioning \Model \Command \ApplyPageEntry ;
1112use Firegento \ContentProvisioning \Model \Query \GetPageEntryByPage ;
1213use 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 ;
1317use Magento \Cms \Controller \Adminhtml \Page \PostDataProcessor ;
1418use Magento \Cms \Model \Page ;
19+ use Magento \Cms \Model \PageFactory ;
1520use Magento \Framework \App \Action \HttpPostActionInterface ;
21+ use Magento \Framework \App \ObjectManager ;
1622use Magento \Framework \App \Request \DataPersistorInterface ;
23+ use Magento \Framework \Controller \ResultInterface ;
1724use Magento \Framework \Exception \LocalizedException ;
1825
1926/**
2027 * Save CMS page action.
2128 */
22- class Save extends \ Magento \ Backend \ App \ Action implements HttpPostActionInterface
29+ class Save extends Action implements HttpPostActionInterface
2330{
2431 /**
2532 * Authorization level of a basic admin session
@@ -39,12 +46,12 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
3946 protected $ dataPersistor ;
4047
4148 /**
42- * @var \Magento\Cms\Model\ PageFactory
49+ * @var PageFactory
4350 */
4451 private $ pageFactory ;
4552
4653 /**
47- * @var \Magento\Cms\Api\ PageRepositoryInterface
54+ * @var PageRepositoryInterface
4855 */
4956 private $ pageRepository ;
5057
@@ -62,25 +69,25 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
6269 * @param Action\Context $context
6370 * @param PostDataProcessor $dataProcessor
6471 * @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
6774 */
6875 public function __construct (
6976 Action \Context $ context ,
7077 PostDataProcessor $ dataProcessor ,
7178 DataPersistorInterface $ dataPersistor ,
7279 GetPageEntryByPage $ getPageEntryByPage ,
7380 ApplyPageEntry $ applyPageEntry ,
74- \ Magento \ Cms \ Model \ PageFactory $ pageFactory = null ,
75- \ Magento \ Cms \ Api \ PageRepositoryInterface $ pageRepository = null
81+ PageFactory $ pageFactory = null ,
82+ PageRepositoryInterface $ pageRepository = null
7683 ) {
7784 $ this ->dataProcessor = $ dataProcessor ;
7885 $ this ->dataPersistor = $ dataPersistor ;
7986 $ this ->pageFactory = $ pageFactory
80- ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()->get (\ Magento \ Cms \ Model \ PageFactory::class);
87+ ?: ObjectManager::getInstance ()->get (PageFactory::class);
8188 $ this ->pageRepository = $ pageRepository
82- ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()
83- ->get (\ Magento \ Cms \ Api \ PageRepositoryInterface::class);
89+ ?: ObjectManager::getInstance ()
90+ ->get (PageRepositoryInterface::class);
8491 parent ::__construct ($ context );
8592 $ this ->getPageEntryByPage = $ getPageEntryByPage ;
8693 $ this ->applyPageEntry = $ applyPageEntry ;
@@ -90,12 +97,12 @@ public function __construct(
9097 * Save action
9198 *
9299 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
93- * @return \Magento\Framework\Controller\ ResultInterface
100+ * @return ResultInterface
94101 */
95102 public function execute ()
96103 {
97104 $ data = $ this ->getRequest ()->getPostValue ();
98- /** @var \Magento\Backend\Model\View\Result\ Redirect $resultRedirect */
105+ /** @var Redirect $resultRedirect */
99106 $ resultRedirect = $ this ->resultRedirectFactory ->create ();
100107 if ($ data ) {
101108 $ data = $ this ->dataProcessor ->filter ($ data );
@@ -106,7 +113,7 @@ public function execute()
106113 $ data ['page_id ' ] = null ;
107114 }
108115
109- /** @var \Magento\Cms\Model\ Page $model */
116+ /** @var Page $model */
110117 $ model = $ this ->pageFactory ->create ();
111118
112119 $ id = $ this ->getRequest ()->getParam ('page_id ' );
@@ -136,7 +143,7 @@ public function execute()
136143 return $ this ->processResultRedirect ($ model , $ resultRedirect , $ data );
137144 } catch (LocalizedException $ e ) {
138145 $ this ->messageManager ->addExceptionMessage ($ e ->getPrevious () ?: $ e );
139- } catch (\ Exception $ e ) {
146+ } catch (Exception $ e ) {
140147 $ this ->messageManager ->addExceptionMessage ($ e , __ ('Something went wrong while saving the page. ' ));
141148 }
142149
@@ -149,10 +156,10 @@ public function execute()
149156 /**
150157 * Process result redirect
151158 *
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
154161 * @param array $data
155- * @return \Magento\Backend\Model\View\Result\ Redirect
162+ * @return Redirect
156163 * @throws LocalizedException
157164 */
158165 private function processResultRedirect ($ model , $ resultRedirect , $ data )
0 commit comments