function drush_config_pages_set_field_value in Config Pages 8.3
Call back function drush_config_pages_set_field_value().
The type of config page. @var string $field_name The name of field. @var string $value The value for the field.
File
- ./
config_pages.drush.inc, line 57 - Contains the code to generate the drush commands.
Code
function drush_config_pages_set_field_value($bundle, $field_name, $value, $context = NULL) {
try {
$config_page = config_pages_config($bundle, $context);
if (empty($config_page)) {
$type = ConfigPagesType::load($bundle);
$config_page = ConfigPages::create([
'type' => $bundle,
'label' => $type
->label(),
'context' => $type
->getContextData(),
]);
$config_page
->save();
}
$append = drush_get_option('append');
if (isset($append)) {
$value = $config_page
->get($field_name)
->getString() . $value;
}
$config_page
->set($field_name, str_replace('\\n', PHP_EOL, $value));
$config_page
->save();
drush_print('Saved new value for ' . $field_name . ' field.');
} catch (Exception $e) {
\Drupal::logger('config_pages')
->error($e
->getMessage());
}
}