Loading drowl_paragraphs.install +13 −25 Original line number Diff line number Diff line Loading @@ -64,8 +64,8 @@ function drowl_paragraphs_update_8003() { */ function drowl_paragraphs_update_8004() { $field_type = 'drowl_paragraphs_settings'; $columns_changed = ['layout_sm_columns', 'layout_md_columns', 'layout_ld_columns']; return _field_type_schema_column_spec_change_helper($field_type, $columns_changed); // $columns_changed = ['layout_sm_columns', 'layout_md_columns', 'layout_ld_columns']; return _field_type_schema_column_spec_change_helper($field_type); } /** Loading Loading @@ -185,8 +185,8 @@ function drowl_paragraphs_update_8302() { */ function drowl_paragraphs_update_8303() { $field_type = 'drowl_paragraphs_settings'; $columns_changed = ['style_boxstyle_outline']; return _field_type_schema_column_spec_change_helper($field_type, $columns_changed); // $columns_changed = ['style_boxstyle_outline']; return _field_type_schema_column_spec_change_helper($field_type); } /** Loading Loading @@ -313,7 +313,7 @@ function _field_type_schema_column_add_helper($field_type, array $columns_to_add } // Add the new column to the installed field schema. if ($field_schema_data) { if (!empty($field_schema_data)) { $field_schema_data[$table]['fields'][$column] = $field_schema['columns'][$column_id]; $field_schema_data[$table]['fields'][$column]['not null'] = FALSE; if ($revision_table) { Loading @@ -324,12 +324,7 @@ function _field_type_schema_column_add_helper($field_type, array $columns_to_add } // Save changes to the installed field schema. if ($field_schema_data) { $recipient_column = $table_mapping->getFieldColumnName($field_storage_definition, 'recipient'); unset($field_schema_data[$table]['fields'][$recipient_column]); if ($revision_table) { unset($field_schema_data[$revision_table]['fields'][$recipient_column]); } if (!empty($field_schema_data)) { $entity_storage_schema_sql->set($schema_key, $field_schema_data); } if ($table_mapping->allowsSharedTableStorage($field_storage_definition)) { Loading @@ -344,14 +339,13 @@ function _field_type_schema_column_add_helper($field_type, array $columns_to_add } /** * Helper function for HOOK_Update to update the field schema columns. * List the columns with changed schema values and the helper will handle * the content migration and entity update for you. * Helper function for HOOK_Update to update the field schema to the latest definition. * * Preserves the existing data. Changes have to be compatible to existing data! * * @param $field_type The field type id e.g. "drowl_paragraphs_settings" * @param array $columns_to_add array of the column names from schema() function, e.g. ["style_textalign"] */ function _field_type_schema_column_spec_change_helper($field_type, $column) { function _field_type_schema_column_spec_change_helper($field_type) { $processed_fields = []; $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $field_definition = $field_type_manager->getDefinition($field_type); Loading Loading @@ -381,8 +375,7 @@ function _field_type_schema_column_spec_change_helper($field_type, $column) { $table = $table_mapping->getFieldTableName($field_name); $tables[] = $table; } catch (SqlContentEntityStorageException $e) { // Custom storage? Broken site? No matter what, if there is no table // or column, there's little we can do. // Custom storage? Broken site? No matter what, if there is no table, there's little we can do. continue; } // See if the field has a revision table. Loading Loading @@ -505,7 +498,7 @@ function _field_type_schema_column_remove_helper($field_type, array $columns_to_ } // Remove the column from the installed field schema. if ($field_schema_data) { if (!empty($field_schema_data)) { unset($field_schema_data[$table]['fields'][$column]); $field_schema_data[$table]['fields'][$column]['not null'] = FALSE; if ($revision_table) { Loading @@ -515,12 +508,7 @@ function _field_type_schema_column_remove_helper($field_type, array $columns_to_ } // Save changes to the installed field schema. if ($field_schema_data) { $recipient_column = $table_mapping->getFieldColumnName($field_storage_definition, 'recipient'); unset($field_schema_data[$table]['fields'][$recipient_column]); if ($revision_table) { unset($field_schema_data[$revision_table]['fields'][$recipient_column]); } if (!empty($field_schema_data)) { $entity_storage_schema_sql->set($schema_key, $field_schema_data); } if ($table_mapping->allowsSharedTableStorage($field_storage_definition)) { Loading Loading
drowl_paragraphs.install +13 −25 Original line number Diff line number Diff line Loading @@ -64,8 +64,8 @@ function drowl_paragraphs_update_8003() { */ function drowl_paragraphs_update_8004() { $field_type = 'drowl_paragraphs_settings'; $columns_changed = ['layout_sm_columns', 'layout_md_columns', 'layout_ld_columns']; return _field_type_schema_column_spec_change_helper($field_type, $columns_changed); // $columns_changed = ['layout_sm_columns', 'layout_md_columns', 'layout_ld_columns']; return _field_type_schema_column_spec_change_helper($field_type); } /** Loading Loading @@ -185,8 +185,8 @@ function drowl_paragraphs_update_8302() { */ function drowl_paragraphs_update_8303() { $field_type = 'drowl_paragraphs_settings'; $columns_changed = ['style_boxstyle_outline']; return _field_type_schema_column_spec_change_helper($field_type, $columns_changed); // $columns_changed = ['style_boxstyle_outline']; return _field_type_schema_column_spec_change_helper($field_type); } /** Loading Loading @@ -313,7 +313,7 @@ function _field_type_schema_column_add_helper($field_type, array $columns_to_add } // Add the new column to the installed field schema. if ($field_schema_data) { if (!empty($field_schema_data)) { $field_schema_data[$table]['fields'][$column] = $field_schema['columns'][$column_id]; $field_schema_data[$table]['fields'][$column]['not null'] = FALSE; if ($revision_table) { Loading @@ -324,12 +324,7 @@ function _field_type_schema_column_add_helper($field_type, array $columns_to_add } // Save changes to the installed field schema. if ($field_schema_data) { $recipient_column = $table_mapping->getFieldColumnName($field_storage_definition, 'recipient'); unset($field_schema_data[$table]['fields'][$recipient_column]); if ($revision_table) { unset($field_schema_data[$revision_table]['fields'][$recipient_column]); } if (!empty($field_schema_data)) { $entity_storage_schema_sql->set($schema_key, $field_schema_data); } if ($table_mapping->allowsSharedTableStorage($field_storage_definition)) { Loading @@ -344,14 +339,13 @@ function _field_type_schema_column_add_helper($field_type, array $columns_to_add } /** * Helper function for HOOK_Update to update the field schema columns. * List the columns with changed schema values and the helper will handle * the content migration and entity update for you. * Helper function for HOOK_Update to update the field schema to the latest definition. * * Preserves the existing data. Changes have to be compatible to existing data! * * @param $field_type The field type id e.g. "drowl_paragraphs_settings" * @param array $columns_to_add array of the column names from schema() function, e.g. ["style_textalign"] */ function _field_type_schema_column_spec_change_helper($field_type, $column) { function _field_type_schema_column_spec_change_helper($field_type) { $processed_fields = []; $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $field_definition = $field_type_manager->getDefinition($field_type); Loading Loading @@ -381,8 +375,7 @@ function _field_type_schema_column_spec_change_helper($field_type, $column) { $table = $table_mapping->getFieldTableName($field_name); $tables[] = $table; } catch (SqlContentEntityStorageException $e) { // Custom storage? Broken site? No matter what, if there is no table // or column, there's little we can do. // Custom storage? Broken site? No matter what, if there is no table, there's little we can do. continue; } // See if the field has a revision table. Loading Loading @@ -505,7 +498,7 @@ function _field_type_schema_column_remove_helper($field_type, array $columns_to_ } // Remove the column from the installed field schema. if ($field_schema_data) { if (!empty($field_schema_data)) { unset($field_schema_data[$table]['fields'][$column]); $field_schema_data[$table]['fields'][$column]['not null'] = FALSE; if ($revision_table) { Loading @@ -515,12 +508,7 @@ function _field_type_schema_column_remove_helper($field_type, array $columns_to_ } // Save changes to the installed field schema. if ($field_schema_data) { $recipient_column = $table_mapping->getFieldColumnName($field_storage_definition, 'recipient'); unset($field_schema_data[$table]['fields'][$recipient_column]); if ($revision_table) { unset($field_schema_data[$revision_table]['fields'][$recipient_column]); } if (!empty($field_schema_data)) { $entity_storage_schema_sql->set($schema_key, $field_schema_data); } if ($table_mapping->allowsSharedTableStorage($field_storage_definition)) { Loading