Skip to content

Commit e2d6415

Browse files
committed
Remove direct use of object manager
added null
1 parent 15100ac commit e2d6415

File tree

1 file changed

+12
-3
lines changed
  • app/code/Magento/Cms/Controller/Adminhtml/Page

1 file changed

+12
-3
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Page/Index.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
use Magento\Framework\App\Action\HttpGetActionInterface;
99
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\App\Request\DataPersistorInterface;
1012
use Magento\Framework\View\Result\PageFactory;
1113

1214
/**
@@ -26,16 +28,24 @@ class Index extends \Magento\Backend\App\Action implements HttpGetActionInterfac
2628
*/
2729
protected $resultPageFactory;
2830

31+
/**
32+
* @var DataPersistorInterface
33+
*/
34+
private $dataPersistor;
35+
2936
/**
3037
* @param Context $context
3138
* @param PageFactory $resultPageFactory
39+
* @param DataPersistorInterface $dataPersistor
3240
*/
3341
public function __construct(
3442
Context $context,
35-
PageFactory $resultPageFactory
43+
PageFactory $resultPageFactory,
44+
DataPersistorInterface $dataPersistor = null
3645
) {
3746
parent::__construct($context);
3847
$this->resultPageFactory = $resultPageFactory;
48+
$this->dataPersistor = $dataPersistor ?: ObjectManager::getInstance()->get(DataPersistorInterface::class);
3949
}
4050

4151
/**
@@ -52,8 +62,7 @@ public function execute()
5262
$resultPage->addBreadcrumb(__('Manage Pages'), __('Manage Pages'));
5363
$resultPage->getConfig()->getTitle()->prepend(__('Pages'));
5464

55-
$dataPersistor = $this->_objectManager->get(\Magento\Framework\App\Request\DataPersistorInterface::class);
56-
$dataPersistor->clear('cms_page');
65+
$this->dataPersistor->clear('cms_page');
5766

5867
return $resultPage;
5968
}

0 commit comments

Comments
 (0)