You are here

public function CacheDecoratedResource::dataProviderFactory in RESTful 7.2

Data provider factory.

Return value

DataProviderInterface The data provider for this resource.

Throws

NotImplementedException

ServerConfigurationException

Overrides ResourceDecoratorBase::dataProviderFactory

1 call to CacheDecoratedResource::dataProviderFactory()
CacheDecoratedResource::getDataProvider in src/Plugin/resource/Decorators/CacheDecoratedResource.php
Gets the data provider.

File

src/Plugin/resource/Decorators/CacheDecoratedResource.php, line 103
Contains \Drupal\restful\Plugin\resource\Decorators\CacheDecoratedResource

Class

CacheDecoratedResource

Namespace

Drupal\restful\Plugin\resource\Decorators

Code

public function dataProviderFactory() {
  if ($this->dataProvider && $this->dataProvider instanceof CacheDecoratedDataProvider) {
    return $this->dataProvider;
  }

  // Get the data provider from the subject of the decorator.
  $decorated_provider = $this->subject
    ->dataProviderFactory();
  $this->dataProvider = new CacheDecoratedDataProvider($decorated_provider, $this
    ->getCacheController());
  $plugin_definition = $this
    ->getPluginDefinition();
  $this->dataProvider
    ->addOptions(array(
    'renderCache' => $this
      ->defaultCacheInfo(),
    'resource' => array(
      'version' => array(
        'major' => $plugin_definition['majorVersion'],
        'minor' => $plugin_definition['minorVersion'],
      ),
      'name' => $plugin_definition['resource'],
    ),
  ));
  return $this->dataProvider;
}