Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Save Class Reference
Inheritance diagram for Save:
Instance HttpPostActionInterface Action ActionInterface AbstractAction Action AbstractAction ActionInterface

Public Member Functions

 execute ()
 
- Public Member Functions inherited from Instance
 __construct (\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Widget\Model\Widget\InstanceFactory $widgetFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Translate\InlineInterface $translateInline)
 
- Public Member Functions inherited from AbstractAction
 __construct (Action\Context $context)
 
 dispatch (\Magento\Framework\App\RequestInterface $request)
 
 _processUrlKeys ()
 
 getUrl ($route='', $params=[])
 
- Public Member Functions inherited from Action
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getActionFlag ()
 
- Public Member Functions inherited from AbstractAction
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getRequest ()
 
 getResponse ()
 

Additional Inherited Members

- Data Fields inherited from Instance
const ADMIN_RESOURCE = 'Magento_Widget::widget_instance'
 
- Data Fields inherited from AbstractAction
const FLAG_IS_URLS_CHECKED = 'check_url_settings'
 
const SESSION_NAMESPACE = 'adminhtml'
 
const ADMIN_RESOURCE = 'Magento_Backend::admin'
 
- Data Fields inherited from ActionInterface
const FLAG_NO_DISPATCH = 'no-dispatch'
 
const FLAG_NO_POST_DISPATCH = 'no-postDispatch'
 
const FLAG_NO_DISPATCH_BLOCK_EVENT = 'no-beforeGenerateLayoutBlocksDispatch'
 
const PARAM_NAME_BASE64_URL = 'r64'
 
const PARAM_NAME_URL_ENCODED = 'uenc'
 
- Protected Member Functions inherited from Instance
 _initAction ()
 
 setBody ($body)
 
- Protected Member Functions inherited from AbstractAction
 _isAllowed ()
 
 _getSession ()
 
 getMessageManager ()
 
 _addBreadcrumb ($label, $title, $link=null)
 
 _addContent (\Magento\Framework\View\Element\AbstractBlock $block)
 
 _addLeft (\Magento\Framework\View\Element\AbstractBlock $block)
 
 _addJs (\Magento\Framework\View\Element\AbstractBlock $block)
 
 _isUrlChecked ()
 
 _processLocaleSettings ()
 
 _redirect ($path, $arguments=[])
 
 _forward ($action, $controller=null, $module=null, array $params=null)
 
 _validateSecretKey ()
 
- Protected Member Functions inherited from Action
 _forward ($action, $controller=null, $module=null, array $params=null)
 
 _redirect ($path, $arguments=[])
 
- Protected Attributes inherited from Instance
 $_coreRegistry
 
 $_widgetFactory
 
 $_logger
 
 $mathRandom
 
 $_translateInline
 
- Protected Attributes inherited from AbstractAction
 $_publicActions = []
 
 $_sessionNamespace = self::SESSION_NAMESPACE
 
 $_helper
 
 $_session
 
 $_authorization
 
 $_auth
 
 $_backendUrl
 
 $_localeResolver
 
 $_canUseBaseUrl
 
 $_formKeyValidator
 
- Protected Attributes inherited from Action
 $_objectManager
 
 $_sessionNamespace
 
 $_eventManager
 
 $_actionFlag
 
 $_redirect
 
 $_view
 
 $_url
 
 $messageManager
 
- Protected Attributes inherited from AbstractAction
 $_request
 
 $_response
 
 $resultRedirectFactory
 
 $resultFactory
 

Detailed Description

Definition at line 11 of file Save.php.

Member Function Documentation

◆ execute()

execute ( )

Save action

Returns
void

Save search term

Returns
Json

Save action

@SuppressWarnings(PHPMD.CyclomaticComplexity)

Returns
\Magento\Framework\Controller\ResultInterface

Save configuration

Returns
\Magento\Backend\Model\View\Result\Redirect

Save invoice We can save only new invoice. Existing invoices are not editable

Returns
\Magento\Framework\Controller\ResultInterface

@SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity) @SuppressWarnings(PHPMD.ExcessiveMethodLength)

Save action

Returns
\Magento\Framework\Controller\ResultInterface

Save shipment We can save only new shipment. Existing shipments are not editable

Returns
void @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)

Implements ActionInterface.

Definition at line 18 of file Save.php.

19  {
20  $widgetInstance = $this->_initWidgetInstance();
21  if (!$widgetInstance) {
22  $this->_redirect('adminhtml/*/');
23  return;
24  }
25  $widgetInstance->setTitle(
26  $this->getRequest()->getPost('title')
27  )->setStoreIds(
28  $this->getRequest()->getPost('store_ids', [0])
29  )->setSortOrder(
30  $this->getRequest()->getPost('sort_order', 0)
31  )->setPageGroups(
32  $this->getRequest()->getPost('widget_instance')
33  )->setWidgetParameters(
34  $this->getRequest()->getPost('parameters')
35  );
36  try {
37  $widgetInstance->save();
38  $this->messageManager->addSuccess(__('The widget instance has been saved.'));
39  if ($this->getRequest()->getParam('back', false)) {
40  $this->_redirect(
41  'adminhtml/*/edit',
42  ['instance_id' => $widgetInstance->getId(), '_current' => true]
43  );
44  } else {
45  $this->_redirect('adminhtml/*/');
46  }
47  return;
48  } catch (\Exception $exception) {
49  $this->messageManager->addError($exception->getMessage());
50  $this->_logger->critical($exception);
51  $this->_redirect('adminhtml/*/edit', ['_current' => true]);
52  return;
53  }
54  }
__()
Definition: __.php:13

The documentation for this class was generated from the following file: