0

Does anybody know, how the mentioned entity types can be setup via configuration Yaml files? Right now I am setting up my entity types for a Kernel Base Test like the following:

Vocabulary::create([
  'name' => 'Kreise',
  'vid' => 'districts',
])->save();

$stringFields = [
  'field_district_number',
];
$this->saveFields($stringFields, 'string', 'districts', 'taxonomy_term');

$booleanFields = [
  'field_searchable'
];
$this->saveFields($booleanFields, 'boolean', 'districts', 'taxonomy_term');

Is it possible to quickly load the entity type configuration by an existing site configuration to save time? Because I already have configured entity types in my site configuration. It seems like an not necessary additional step, to code the entity configuration for my test.

1 Answer 1

0

Here is documentation for using the configuration. So for example, if you want to load Tags Vocabulary you will do:

$config = \Drupal::service('config.factory')->getEditable('taxonomy.vocabulary.tags');
$description = $config->get('description');

$description contains the description of the vocabulary. In this way, you can load what you want from the yml file.

1
  • Loading the description is not loading the entity type configuration tho. I would image you need to load the configuration of the entity after exporting the config?
    – AlxVallejo
    Apr 17, 2020 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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