3 namespace Drupal\Core\Field;
5 use Drupal\Core\Config\Entity\ConfigEntityStorage;
6 use Drupal\Core\Entity\EntityInterface;
9 * Base storage class for field config entities.
11 abstract class FieldConfigStorageBase extends ConfigEntityStorage {
14 * The field type plugin manager.
16 * @var \Drupal\Core\Field\FieldTypePluginManagerInterface
18 protected $fieldTypeManager;
23 protected function mapFromStorageRecords(array $records) {
24 foreach ($records as $id => &$record) {
25 $class = $this->fieldTypeManager->getPluginClass($record['field_type']);
27 $config_id = $this->getPrefix() . $id;
28 throw new \RuntimeException("Unable to determine class for field type '{$record['field_type']}' found in the '$config_id' configuration");
30 $record['settings'] = $class::fieldSettingsFromConfigData($record['settings']);
32 return parent::mapFromStorageRecords($records);
38 protected function mapToStorageRecord(EntityInterface $entity) {
39 $record = parent::mapToStorageRecord($entity);
40 $class = $this->fieldTypeManager->getPluginClass($record['field_type']);
41 $record['settings'] = $class::fieldSettingsToConfigData($record['settings']);