Automattic\WooCommerce\Database\Migrations
MetaToCustomTableMigrator::process_and_sanitize_entity_data()
Helper method to sanitize core source table.
Method of the class: MetaToCustomTableMigrator{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->process_and_sanitize_entity_data( $sanitized_entity_data, $error_records, $entity_data ): void;
- $sanitized_entity_data(array) (required)
- Array containing sanitized data for insertion.
- $error_records(array) (required)
- Error records.
- $entity_data(array) (required)
- Original source data.
MetaToCustomTableMigrator::process_and_sanitize_entity_data() MetaToCustomTableMigrator::process and sanitize entity data code WC 9.7.1
private function process_and_sanitize_entity_data( array &$sanitized_entity_data, array &$error_records, array $entity_data ): void { foreach ( $entity_data as $entity ) { $row_data = array(); foreach ( $this->core_column_mapping as $column_name => $schema ) { $custom_table_column_name = $schema['destination'] ?? $column_name; $value = $entity->$column_name; $value = $this->validate_data( $value, $schema['type'] ); if ( is_wp_error( $value ) ) { $error_records[ $entity->primary_key_id ][ $custom_table_column_name ] = $value->get_error_code(); } else { $row_data[ $custom_table_column_name ] = $value; } } $sanitized_entity_data[ $entity->entity_meta_rel_id ] = $row_data; } }