Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExportButton.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Ui\Component;
7 
10 
15 {
19  const NAME = 'exportButton';
20 
24  protected $urlBuilder;
25 
32  public function __construct(
35  array $components = [],
36  array $data = []
37  ) {
38  parent::__construct($context, $components, $data);
39  $this->urlBuilder = $urlBuilder;
40  }
41 
47  public function getComponentName()
48  {
49  return static::NAME;
50  }
51 
55  public function prepare()
56  {
57  $context = $this->getContext();
58  $config = $this->getData('config');
59  if (isset($config['options'])) {
60  $options = [];
61  foreach ($config['options'] as $option) {
62  $additionalParams = $this->getAdditionalParams($config, $context);
63  $option['url'] = $this->urlBuilder->getUrl($option['url'], $additionalParams);
64  $options[] = $option;
65  }
66  $config['options'] = $options;
67  $this->setData('config', $config);
68  }
69  parent::prepare();
70  }
71 
79  protected function getAdditionalParams($config, $context)
80  {
81  $additionalParams = [];
82  if (isset($config['additionalParams'])) {
83  foreach ($config['additionalParams'] as $paramName => $paramValue) {
84  if ('*' == $paramValue) {
85  $paramValue = $context->getRequestParam($paramName);
86  }
87  $additionalParams[$paramName] = $paramValue;
88  }
89  }
90  return $additionalParams;
91  }
92 }
getAdditionalParams($config, $context)
$config
Definition: fraud_order.php:17
__construct(ContextInterface $context, UrlInterface $urlBuilder, array $components=[], array $data=[])