本文整理汇总了PHP中Magento\Backend\Model\Session::setMageplazaBlogTopicData方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::setMageplazaBlogTopicData方法的具体用法?PHP Session::setMageplazaBlogTopicData怎么用?PHP Session::setMageplazaBlogTopicData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\Model\Session
的用法示例。
在下文中一共展示了Session::setMageplazaBlogTopicData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* run the action
*
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
{
$data = $this->getRequest()->getPost('topic');
$resultRedirect = $this->resultRedirectFactory->create();
if ($data) {
$topic = $this->initTopic();
$topic->setData($data);
$posts = $this->getRequest()->getPost('posts', -1);
if ($posts != -1) {
$topic->setPostsData($this->jsHelper->decodeGridSerializedInput($posts));
}
$this->_eventManager->dispatch('mageplaza_blog_topic_prepare_save', ['topic' => $topic, 'request' => $this->getRequest()]);
try {
$topic->save();
$this->messageManager->addSuccess(__('The Topic has been saved.'));
$this->backendSession->setMageplazaBlogTopicData(false);
if ($this->getRequest()->getParam('back')) {
$resultRedirect->setPath('mageplaza_blog/*/edit', ['topic_id' => $topic->getId(), '_current' => true]);
return $resultRedirect;
}
$resultRedirect->setPath('mageplaza_blog/*/');
return $resultRedirect;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\RuntimeException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Something went wrong while saving the Topic.'));
}
$this->_getSession()->setMageplazaBlogTopicData($data);
$resultRedirect->setPath('mageplaza_blog/*/edit', ['topic_id' => $topic->getId(), '_current' => true]);
return $resultRedirect;
}
$resultRedirect->setPath('mageplaza_blog/*/');
return $resultRedirect;
}