2

I try to import specific configuration. I use this :

$config_path = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
$source = new FileStorage($config_path);

$config_storage = \Drupal::service('config.storage');
$config_factory = \Drupal::configFactory();
$uuid_service = \Drupal::service('uuid');

$configs = [
  'field.storage.config_pages.field_areas',
  'field.field.config_pages.configuration_implantation_page.field_areas',
  'core.entity_form_display.config_pages.configuration_implantation_page.default',
  'core.entity_view_display.config_pages.configuration_implantation_page.default',
];

$config_storage->write('field.storage.config_pages.field_areas', $source->read('field.storage.config_pages.field_areas'));
$config_storage->write('field.field.config_pages.configuration_implantation_page.field_areas', $source->read('field.field.config_pages.configuration_implantation_page.field_areas'));
$config_storage->write('core.entity_form_display.config_pages.configuration_implantation_page.default', $source->read('core.entity_form_display.config_pages.configuration_implantation_page.default'));
$config_storage->write('core.entity_view_display.config_pages.configuration_implantation_page.default', $source->read('core.entity_view_display.config_pages.configuration_implantation_page.default'));

If the field is created, the table is not created.

How to create the tables associated?

  • I believe the system will create the table when you first try to save some data to it – Clive Sep 27 '19 at 9:24
  • Try to add $config_storage->save(); – berramou Sep 27 '19 at 9:54
  • Take a look metaltoad.com/blog/… – berramou Sep 27 '19 at 9:55
  • @berramou, post this as an answer. The important thing is not simply store config, but create and save config entities and so run CRUD methods/hooks like FieldStorageConfig::preSave – 4k4 Sep 27 '19 at 12:00
0

You should save the config like $config_storage->save(); :
As @4K4 mentioned :

The important thing is not simply store config, but create and save config entities and so run CRUD methods/hooks like https://api.drupal.org/api/drupal/core%21modules%21field%21src%21Entity%21FieldStorageConfig.php/function/FieldStorageConfig%3A%3ApreSave/8.7.x

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.