I am trying to make a tabular/grid view in the Admin area for some data that comes from an external API. For that I implemented a data provider. In here I need to create an instance for the external API client with the config stored in the store settings.
However, I am not sure how to inject or retrieve these settings in the data provider:
class ListingDataProvider extends MagentoFrameworkViewElementUiComponentDataProviderDataProvider
{
...
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
ReportingInterface $reporting,
SearchCriteriaBuilder $searchCriteriaBuilder,
RequestInterface $request,
FilterBuilder $filterBuilder,
array $meta = [],
array $data = [],
ScopeConfigInterface $scopeConfig <---- Is this possible?
) {
$this->request = $request;
$this->filterBuilder = $filterBuilder;
$this->name = $name;
$this->primaryFieldName = $primaryFieldName;
$this->requestFieldName = $requestFieldName;
$this->reporting = $reporting;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->meta = $meta;
$this->data = $data;
$this->prepareUpdateUrl();
}
...
}
This is my (probably wrong) di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="SomeModuleUiDataProviderAdministrationListingDataProvider">
<plugin name="some_module_attributes" type="SomeModulePluginAddAttributesToUiDataProvider"/>
</type>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="some_module__administration_listing_data_source" xsi:type="string">SomeModuleAdministrationCollection</item>
</argument>
</arguments>
</type>
// Not quite sure how should this be replaced
<virtualType name="SomeModuleAdministrationCollection" type="SomeModuleUiDataProviderAdministrationListingCollection">
<arguments>
<argument name="mainTable" xsi:type="string">catalog_category_entity</argument>
<argument name="resourceModel" xsi:type="string">SomeModuleModelResourceModelAdministration</argument>
</arguments>
</virtualType>
</config>
I am sure the above is wrong, as i do not have a mainTable.
But, is it possible to inject the config?
Or, if I inject the config paths, how would I retrieve them in the provider class itself?
Thanks!