You are here

public function EntityDataProviderManager::registerDataProvider in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 src/DataProvider/EntityDataProviderManager.php \Drupal\gutenberg\DataProvider\EntityDataProviderManager::registerDataProvider()

Register entity type data provider.

Parameters

\Drupal\gutenberg\DataProvider\DataProviderInterface $data_provider: Data provider to register.

string $entity_type: Entity type machine name.

Throws

\Exception

Overrides EntityDataProviderManagerInterface::registerDataProvider

File

src/DataProvider/EntityDataProviderManager.php, line 24

Class

EntityDataProviderManager
Supports management for entity type data providers.

Namespace

Drupal\gutenberg\DataProvider

Code

public function registerDataProvider(DataProviderInterface $data_provider, string $entity_type) {
  if ($this
    ->isRegistered($entity_type)) {
    throw new \Exception(sprintf('Data provider for %s entity type does already exist.', $entity_type));
  }
  $this->dataProviders[$entity_type] = $data_provider;
}