NotificationDataProvider.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ReleaseNotification\Ui\DataProvider;
  7. use Magento\Framework\Api\Search\SearchCriteriaInterface;
  8. use Magento\Framework\Api\Search\SearchResultInterface;
  9. use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface;
  10. use Magento\Ui\DataProvider\Modifier\ModifierInterface;
  11. use Magento\Ui\DataProvider\Modifier\PoolInterface;
  12. /**
  13. * Data Provider for the Release Notifications UI component.
  14. */
  15. class NotificationDataProvider implements DataProviderInterface
  16. {
  17. /**
  18. * @var PoolInterface
  19. */
  20. private $pool;
  21. /**
  22. * Search result object.
  23. *
  24. * @var SearchResultInterface
  25. */
  26. private $searchResult;
  27. /**
  28. * Search criteria object.
  29. *
  30. * @var SearchCriteriaInterface
  31. */
  32. private $searchCriteria;
  33. /**
  34. * Own name of this provider.
  35. *
  36. * @var string
  37. */
  38. private $name;
  39. /**
  40. * Provider configuration data.
  41. *
  42. * @var array
  43. */
  44. private $data;
  45. /**
  46. * Provider configuration meta.
  47. *
  48. * @var array
  49. */
  50. private $meta;
  51. /**
  52. * @param string $name
  53. * @param SearchResultInterface $searchResult
  54. * @param SearchCriteriaInterface $searchCriteria
  55. * @param PoolInterface $pool
  56. * @param array $meta
  57. * @param array $data
  58. */
  59. public function __construct(
  60. $name,
  61. SearchResultInterface $searchResult,
  62. SearchCriteriaInterface $searchCriteria,
  63. PoolInterface $pool,
  64. array $meta = [],
  65. array $data = []
  66. ) {
  67. $this->name = $name;
  68. $this->searchResult = $searchResult;
  69. $this->searchCriteria = $searchCriteria;
  70. $this->pool = $pool;
  71. $this->meta = $meta;
  72. $this->data = $data;
  73. }
  74. /**
  75. * @inheritdoc
  76. */
  77. public function getData()
  78. {
  79. /** @var ModifierInterface $modifier */
  80. foreach ($this->pool->getModifiersInstances() as $modifier) {
  81. $this->data = $modifier->modifyData($this->data);
  82. }
  83. return $this->data;
  84. }
  85. /**
  86. * @inheritdoc
  87. */
  88. public function getMeta()
  89. {
  90. /** @var ModifierInterface $modifier */
  91. foreach ($this->pool->getModifiersInstances() as $modifier) {
  92. $this->meta = $modifier->modifyMeta($this->meta);
  93. }
  94. return $this->meta;
  95. }
  96. /**
  97. * @inheritdoc
  98. */
  99. public function getName()
  100. {
  101. return $this->name;
  102. }
  103. /**
  104. * @inheritdoc
  105. */
  106. public function getConfigData()
  107. {
  108. return $this->data['config'] ?? [];
  109. }
  110. /**
  111. * @inheritdoc
  112. */
  113. public function setConfigData($config)
  114. {
  115. $this->data['config'] = $config;
  116. return true;
  117. }
  118. /**
  119. * @inheritdoc
  120. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  121. */
  122. public function getFieldMetaInfo($fieldSetName, $fieldName)
  123. {
  124. return [];
  125. }
  126. /**
  127. * @inheritdoc
  128. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  129. */
  130. public function getFieldSetMetaInfo($fieldSetName)
  131. {
  132. return [];
  133. }
  134. /**
  135. * @inheritdoc
  136. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  137. */
  138. public function getFieldsMetaInfo($fieldSetName)
  139. {
  140. return [];
  141. }
  142. /**
  143. * @inheritdoc
  144. */
  145. public function getPrimaryFieldName()
  146. {
  147. return 'release_notification';
  148. }
  149. /**
  150. * @inheritdoc
  151. */
  152. public function getRequestFieldName()
  153. {
  154. return 'release_notification';
  155. }
  156. /**
  157. * @inheritdoc
  158. */
  159. public function addFilter(\Magento\Framework\Api\Filter $filter)
  160. {
  161. }
  162. /**
  163. * @inheritdoc
  164. */
  165. public function addOrder($field, $direction)
  166. {
  167. }
  168. /**
  169. * @inheritdoc
  170. */
  171. public function setLimit($offset, $size)
  172. {
  173. }
  174. /**
  175. * @inheritdoc
  176. */
  177. public function getSearchCriteria()
  178. {
  179. return $this->searchCriteria;
  180. }
  181. /**
  182. * @inheritdoc
  183. */
  184. public function getSearchResult()
  185. {
  186. return $this->searchResult;
  187. }
  188. }