Newer
Older
$config_dir = new FileStorage($path);
// Get the name of the field.
$name = 'field.field.node.' . $content_type . '.field_path';
// Get the config from the yml into an array.
$config_record = $config_dir->read($name);
if ($config_record) {
// If the field config is not install, install it.
if (!FieldConfig::loadByName(
$config_record['entity_type'],
$config_record['bundle'],
$config_record['field_name'])
) {
FieldConfig::create($config_record)->save();
}
}