class EntityDataProviderManager in Gutenberg 8.2
Same name and namespace in other branches
- 8 src/DataProvider/EntityDataProviderManager.php \Drupal\gutenberg\DataProvider\EntityDataProviderManager
Supports management for entity type data providers.
@package Drupal\gutenberg\DataProvider
Hierarchy
- class \Drupal\gutenberg\DataProvider\EntityDataProviderManager implements EntityDataProviderManagerInterface
Expanded class hierarchy of EntityDataProviderManager
1 file declares its use of EntityDataProviderManager
- MediaService.php in src/
Service/ MediaService.php
1 string reference to 'EntityDataProviderManager'
1 service uses EntityDataProviderManager
File
- src/
DataProvider/ EntityDataProviderManager.php, line 12
Namespace
Drupal\gutenberg\DataProviderView source
class EntityDataProviderManager implements EntityDataProviderManagerInterface {
/**
* Array of registered data providers.
*
* @var array
*/
protected $dataProviders = [];
/**
* {@inheritDoc}
*/
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;
}
/**
* {@inheritDoc}
*/
public function getData(string $entity_type, ContentEntityInterface $entity, array $data = []) {
if (!$this
->isRegistered($entity_type)) {
throw new \Exception(sprintf("Data type doesn't exist for %s entity type.", $entity_type));
}
return $this->dataProviders[$entity_type]
->getData($entity, $data);
}
/**
* {@inheritDoc}
*/
public function isRegistered(string $data_provider) {
return array_key_exists($data_provider, $this->dataProviders);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityDataProviderManager:: |
protected | property | Array of registered data providers. | |
EntityDataProviderManager:: |
public | function |
Get data for specified entity type. Overrides EntityDataProviderManagerInterface:: |
|
EntityDataProviderManager:: |
public | function |
Check if data provider for specified entity type exists. Overrides EntityDataProviderManagerInterface:: |
|
EntityDataProviderManager:: |
public | function |
Register entity type data provider. Overrides EntityDataProviderManagerInterface:: |