本文整理汇总了PHP中Magento\Framework\App\RequestInterface::getPostValue方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getPostValue方法的具体用法?PHP RequestInterface::getPostValue怎么用?PHP RequestInterface::getPostValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getPostValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeExecute
/**
* @param Attribute\Save $subject
* @param RequestInterface $request
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeExecute(Attribute\Save $subject, RequestInterface $request)
{
$data = $request->getPostValue();
if (isset($data['frontend_input'])) {
switch ($data['frontend_input']) {
case 'swatch_visual':
$data[Swatch::SWATCH_INPUT_TYPE_KEY] = Swatch::SWATCH_INPUT_TYPE_VISUAL;
$data['frontend_input'] = 'select';
$request->setPostValue($data);
break;
case 'swatch_text':
$data[Swatch::SWATCH_INPUT_TYPE_KEY] = Swatch::SWATCH_INPUT_TYPE_TEXT;
$data['use_product_image_for_swatch'] = 0;
$data['frontend_input'] = 'select';
$request->setPostValue($data);
break;
case 'select':
$data[Swatch::SWATCH_INPUT_TYPE_KEY] = Swatch::SWATCH_INPUT_TYPE_DROPDOWN;
$data['frontend_input'] = 'select';
$request->setPostValue($data);
break;
}
}
return [$request];
}
示例2: dispatch
/**
* Check if module is enabled
* If allow only for customer - redirect to login page
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
* @throws \Magento\Framework\Exception\NotFoundException
*/
public function dispatch(RequestInterface $request)
{
/* @var $helper \Magento\Sendfriend\Helper\Data */
$helper = $this->_objectManager->get('Magento\\Sendfriend\\Helper\\Data');
/* @var $session \Magento\Customer\Model\Session */
$session = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
if (!$helper->isEnabled()) {
throw new NotFoundException(__('Page not found.'));
}
if (!$helper->isAllowForGuest() && !$session->authenticate($this)) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
if ($this->getRequest()->getActionName() == 'sendemail') {
$session->setBeforeAuthUrl($this->_url->getUrl('sendfriend/product/send', ['_current' => true]));
$this->_objectManager->get('Magento\\Catalog\\Model\\Session')->setSendfriendFormData($request->getPostValue());
}
}
return parent::dispatch($request);
}
示例3: loadValidOrder
/**
* Try to load valid order by $_POST or $_COOKIE
*
* @param App\RequestInterface $request
* @return \Magento\Framework\Controller\Result\Redirect|bool
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function loadValidOrder(App\RequestInterface $request)
{
if ($this->customerSession->isLoggedIn()) {
return $this->resultRedirectFactory->create()->setPath('sales/order/history');
}
$post = $request->getPostValue();
$errors = false;
/** @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create();
$fromCookie = $this->cookieManager->getCookie(self::COOKIE_NAME);
if (empty($post) && !$fromCookie) {
return $this->resultRedirectFactory->create()->setPath('sales/guest/form');
} elseif (!empty($post) && isset($post['oar_order_id']) && isset($post['oar_type'])) {
$type = $post['oar_type'];
$incrementId = $post['oar_order_id'];
$lastName = $post['oar_billing_lastname'];
$email = $post['oar_email'];
$zip = $post['oar_zip'];
$storeId = $this->_storeManager->getStore()->getId();
if (empty($incrementId) || empty($lastName) || empty($type) || empty($storeId) || !in_array($type, ['email', 'zip']) || $type == 'email' && empty($email) || $type == 'zip' && empty($zip)) {
$errors = true;
}
if (!$errors) {
$order = $order->loadByIncrementIdAndStoreId($incrementId, $storeId);
}
$errors = true;
if ($order->getId()) {
$billingAddress = $order->getBillingAddress();
if (strtolower($lastName) == strtolower($billingAddress->getLastname()) && ($type == 'email' && strtolower($email) == strtolower($billingAddress->getEmail()) || $type == 'zip' && strtolower($zip) == strtolower($billingAddress->getPostcode()))) {
$errors = false;
}
}
if (!$errors) {
$toCookie = base64_encode($order->getProtectCode() . ':' . $incrementId);
$this->setGuestViewCookie($toCookie);
}
} elseif ($fromCookie) {
$cookieData = explode(':', base64_decode($fromCookie));
$protectCode = isset($cookieData[0]) ? $cookieData[0] : null;
$incrementId = isset($cookieData[1]) ? $cookieData[1] : null;
$errors = true;
if (!empty($protectCode) && !empty($incrementId)) {
$order->loadByIncrementId($incrementId);
if ($order->getProtectCode() === $protectCode) {
// renew cookie
$this->setGuestViewCookie($fromCookie);
$errors = false;
}
}
}
if (!$errors && $order->getId()) {
$this->coreRegistry->register('current_order', $order);
return true;
}
$this->messageManager->addError(__('You entered incorrect data. Please try again.'));
return $this->resultRedirectFactory->create()->setPath('sales/guest/form');
}
示例4: _checkShouldBeSecure
/**
* Check that request uses https protocol if it should.
* Function redirects user to correct URL if needed.
*
* @param \Magento\Framework\App\RequestInterface $request
* @param string $path
* @return void
* @SuppressWarnings(PHPMD.ExitExpression)
*/
protected function _checkShouldBeSecure(\Magento\Framework\App\RequestInterface $request, $path = '')
{
if ($request->getPostValue()) {
return;
}
if ($this->pathConfig->shouldBeSecure($path) && !$request->isSecure()) {
$url = $this->pathConfig->getCurrentSecureUrl($request);
if ($this->_shouldRedirectToSecure()) {
$url = $this->_url->getRedirectUrl($url);
}
$this->_responseFactory->create()->setRedirect($url)->sendResponse();
exit;
}
}