Skip to content

7.3. Assigning a different data provider

Dane Rossenrode edited this page Apr 9, 2016 · 1 revision

You can change the data provider class that your resource classes use. To do so, you will need to override the dataProviderClassName method in your resource.

The following example sets DataProviderCustomBarry (which is an imaginary custom data provider) as the data provider for the Barry__1_0 resource.

class Barry__1_0 extends ResourceNode implements ResourceInterface {
  protected function publicFields() {
    ...etc...
  }

  /**
   * {@inheritdoc}
   */
  protected function dataProviderClassName() {
    return '\Drupal\my_module\Plugin\DataProvider\DataProviderCustomBarry';
  }
}

Clone this wiki locally