本文整理汇总了PHP中Magento\Framework\App\Request\Http::getPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::getPost方法的具体用法?PHP Http::getPost怎么用?PHP Http::getPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Request\Http
的用法示例。
在下文中一共展示了Http::getPost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Before model save
* @param \Magefan\Blog\Model\Post $model
* @param \Magento\Framework\App\Request\Http $request
* @return void
*/
protected function _beforeSave($model, $request)
{
/* Prepare dates */
$dateFilter = $this->_objectManager->create('Magento\\Framework\\Stdlib\\DateTime\\Filter\\Date');
$data = $model->getData();
$filterRules = [];
foreach (['publish_time', 'custom_theme_from', 'custom_theme_to'] as $dateField) {
if (!empty($data[$dateField])) {
$filterRules[$dateField] = $dateFilter;
}
}
$inputFilter = new \Zend_Filter_Input($filterRules, [], $data);
$data = $inputFilter->getUnescaped();
$model->setData($data);
/* Prepare author */
if (!$model->getAuthorId()) {
$authSession = $this->_objectManager->get('Magento\\Backend\\Model\\Auth\\Session');
$model->setAuthorId($authSession->getUser()->getId());
}
/* Prepare relative links */
$data = $request->getPost('data');
$links = isset($data['links']) ? $data['links'] : null;
if ($links && is_array($links)) {
foreach (['post', 'product'] as $linkType) {
if (!empty($links[$linkType]) && is_array($links[$linkType])) {
$linksData = [];
foreach ($links[$linkType] as $item) {
$linksData[$item['id']] = ['position' => $item['position']];
}
$links[$linkType] = $linksData;
}
}
$model->setData('links', $links);
}
/* Prepare images */
$data = $model->getData();
foreach (['featured_img', 'og_img'] as $key) {
if (isset($data[$key]) && is_array($data[$key])) {
if (!empty($data[$key]['delete'])) {
$model->setData($key, null);
} else {
if (isset($data[$key][0]['name']) && isset($data[$key][0]['tmp_name'])) {
$image = $data[$key][0]['name'];
$model->setData($key, Post::BASE_MEDIA_PATH . DIRECTORY_SEPARATOR . $image);
$imageUploader = $this->_objectManager->get('Magefan\\Blog\\ImageUpload');
$imageUploader->moveFileFromTmp($image);
} else {
if (isset($data[$key][0]['name'])) {
$model->setData($key, $data[$key][0]['name']);
}
}
}
} else {
$model->setData($key, null);
}
}
}