Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PostHelper.php
Go to the documentation of this file.
1 <?php
11 
13 use Magento\Framework\Url\Helper\Data as UrlHelper;
14 
16 {
20  private $urlHelper;
21 
26  public function __construct(
27  Context $context,
28  UrlHelper $urlHelper
29  ) {
30  parent::__construct($context);
31  $this->urlHelper = $urlHelper;
32  }
33 
41  public function getPostData($url, array $data = [])
42  {
43  if (!isset($data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED])) {
44  $data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl();
45  }
46  return json_encode(['action' => $url, 'data' => $data]);
47  }
48 }
getPostData($url, array $data=[])
Definition: PostHelper.php:41
__construct(Context $context, UrlHelper $urlHelper)
Definition: PostHelper.php:26
Definition: PostHelper.php:15