8

What is Data Persistor? How and when it can be used?

I can see its usage in

vendor/magento/module-cms/Controller/Adminhtml/Page/Index.php

inside execute() method

$dataPersistor = $this->_objectManager->get(\Magento\Framework\App\Request\DataPersistorInterface::class);
$dataPersistor->clear('cms_page');
1
  • does my answer, answers or helps your question? Commented Mar 27, 2018 at 15:36

1 Answer 1

10

Its just a class which stores data to the current user session. You can set, get and clear data from the session.

Have a look at the \Magento\Framework\App\Request\DataPersistor class SessionManagerInterface is used in every method.

You could use this to store temporary data to be used across the framework which don't need to be stored otherwise in the database.

What are sessions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.