Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataProvider.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Search\Model\ResourceModel\SynonymGroup\CollectionFactory;
10 
15 {
19  protected $collection;
20 
24  protected $filterPool;
25 
29  protected $loadedData;
30 
42  public function __construct(
43  $name,
46  CollectionFactory $blockCollectionFactory,
48  array $meta = [],
49  array $data = []
50  ) {
51  parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
52  $this->collection = $blockCollectionFactory->create();
53  $this->filterPool = $filterPool;
54  }
55 
61  public function getData()
62  {
63  if (isset($this->loadedData)) {
64  return $this->loadedData;
65  }
66  $items = $this->collection->getItems();
68  foreach ($items as $synGroup) {
69  // Set the virtual 'scope_id' column to appropriate value.
70  // This is necessary to display the correct selection set
71  // in 'scope' field on the GUI.
72  $synGroup->setScope();
73  $this->loadedData[$synGroup->getId()] = $synGroup->getData();
74  }
75  return $this->loadedData;
76  }
77 }
__construct( $name, $primaryFieldName, $requestFieldName, CollectionFactory $blockCollectionFactory, FilterPool $filterPool, array $meta=[], array $data=[])
$items