updated features

This commit is contained in:
Bachir Soussi Chiadmi
2016-04-19 16:32:54 +02:00
parent fb0666538c
commit e2fde76aff
13 changed files with 295 additions and 190 deletions

View File

@@ -158,7 +158,7 @@ function field_base_features_export_render($module, $data, $export = NULL) {
unset($field['storage']);
}
// If we still have a storage declaration here it means that a non-default
// storage type was altered into to the field definition. And noone would
// storage type was altered into to the field definition. And no one would
// never need to change the 'details' key, so don't render it.
if (isset($field['storage']['details'])) {
unset($field['storage']['details']);
@@ -170,10 +170,10 @@ function field_base_features_export_render($module, $data, $export = NULL) {
$field_identifier = features_var_export($identifier);
if (features_field_export_needs_wrap($field_prefix, $field_identifier)) {
$code[] = rtrim($field_prefix);
$code[] = " // {$field_identifier}";
$code[] = " // {$field_identifier}.";
}
else {
$code[] = $field_prefix . $field_identifier;
$code[] = $field_prefix . $field_identifier . '.';
}
$code[] = " \$field_bases[{$field_identifier}] = {$field_export};";
$code[] = "";
@@ -201,10 +201,10 @@ function field_instance_features_export_render($module, $data, $export = NULL) {
$instance_identifier = features_var_export($identifier);
if (features_field_export_needs_wrap($instance_prefix, $instance_identifier)) {
$code[] = rtrim($instance_prefix);
$code[] = " // {$instance_identifier}";
$code[] = " // {$instance_identifier}.";
}
else {
$code[] = $instance_prefix . $instance_identifier;
$code[] = $instance_prefix . $instance_identifier . '.';
}
$code[] = " \$field_instances[{$instance_identifier}] = {$field_export};";
$code[] = "";
@@ -276,11 +276,21 @@ function field_base_features_rebuild($module) {
$existing_field = $existing_fields[$field['field_name']];
$array_diff_result = drupal_array_diff_assoc_recursive($field + $existing_field, $existing_field);
if (!empty($array_diff_result)) {
field_update_field($field);
try {
field_update_field($field);
}
catch (FieldException $e) {
watchdog('features', 'Attempt to update field %label failed: %message', array('%label' => $field['field_name'], '%message' => $e->getMessage()), WATCHDOG_ERROR);
}
}
}
else {
field_create_field($field);
try {
field_create_field($field);
}
catch (FieldException $e) {
watchdog('features', 'Attempt to create field %label failed: %message', array('%label' => $field['field_name'], '%message' => $e->getMessage()), WATCHDOG_ERROR);
}
$existing_fields[$field['field_name']] = $field;
}
variable_set('menu_rebuild_needed', TRUE);
@@ -410,7 +420,7 @@ function field_features_export_render($module, $data, $export = NULL) {
unset($field['field_config']['storage']);
}
// If we still have a storage declaration here it means that a non-default
// storage type was altered into to the field definition. And noone would
// storage type was altered into to the field definition. And no one would
// never need to change the 'details' key, so don't render it.
if (isset($field['field_config']['storage']['details'])) {
unset($field['field_config']['storage']['details']);
@@ -562,5 +572,6 @@ function features_field_load($identifier) {
* @see https://www.drupal.org/node/1354
*/
function features_field_export_needs_wrap($prefix, $identifier) {
return (strlen($prefix) + strlen($identifier) > 80);
// Check for 79 characters, since the comment ends with a full stop.
return (strlen($prefix) + strlen($identifier) > 79);
}