Refactor `read_meta` into filter_raw_data for better re-usability.

This commit is contained in:
vedanshujain 2020-06-24 19:39:11 +05:30
parent f80a67b05a
commit 44a226941d
1 changed files with 11 additions and 0 deletions

View File

@ -94,7 +94,18 @@ class WC_Data_Store_WP {
$object->get_id()
)
);
return $this->filter_raw_data( $object, $raw_meta_data );
}
/**
* Helper method to filter internal meta keys from all meta data rows for the object.
*
* @param WC_Data $object WC_Data object.
* @param array $raw_meta_data Array of std object of meta data to be filtered.
*
* @return mixed|void
*/
public function filter_raw_data( &$object, $raw_meta_data ) {
$this->internal_meta_keys = array_merge( array_map( array( $this, 'prefix_key' ), $object->get_data_keys() ), $this->internal_meta_keys );
$meta_data = array_filter( $raw_meta_data, array( $this, 'exclude_internal_meta_keys' ) );
return apply_filters( "woocommerce_data_store_wp_{$this->meta_type}_read_meta", $meta_data, $object, $this );