Skip to content
This repository has been archived by the owner on Nov 28, 2019. It is now read-only.

Commit

Permalink
Update signature of w2m_import_meta_not_filterable
Browse files Browse the repository at this point in the history
Use Type\MetaIndexRecord types to address unfilterable meta records.
Those will be stored in object storages to be quickly iteratable #56
  • Loading branch information
dnaber-de committed Feb 17, 2016
1 parent 87d7888 commit cba6f4b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions inc/Import/Filter/ImportMetaFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function filter_value( Type\ImportMetaInterface $meta, $object_id ) {
return $this->apply_filters( $meta, $meta->value(), $object_id );

$value = [];
foreach ( $meta->value() as $v ) {
$value[] = $this->apply_filters( $meta, $v, $object_id );
foreach ( $meta->value() as $index => $v ) {
$value[] = $this->apply_filters( $meta, $v, $object_id, $index );
}

return $value;
Expand All @@ -60,25 +60,24 @@ public function filter_value( Type\ImportMetaInterface $meta, $object_id ) {
* @param Type\ImportMetaInterface $meta
* @param string $value
* @param int $object_id
* @param int $index (Index of the meta record for multiple meta data)
*
* @return mixed
*/
public function apply_filters( Type\ImportMetaInterface $meta, $value, $object_id ) {
public function apply_filters( Type\ImportMetaInterface $meta, $value, $object_id, $index = 0 ) {

$filters = $this->filter_list->get_filters( $this->type, $meta->key() );
foreach ( $filters as $filter ) {
if ( ! $filter->is_filterable( $meta->value(), $object_id ) ) {
$meta_index = new Type\WpMetaRecordIndex( $meta->key(), $object_id, $index, $this->type );
/**
* Fires when a filter is invalid (due to missing data)
*
* Todo: Check if these parameter are sufficient for multiple meta records!
*
* @param string $type ('post', 'comment', 'user' or 'term')
* @param int $object_id
* @param Type\ImportMetaInterface $meta
* @param Filter\ValueFilterableInterface $filter
* @param Type\MetaRecordIndexInterface $meta_index
* @param Type\ImportMetaInterface $meta
*/
do_action( 'w2m_import_meta_not_filterable', $this->type, $object_id, $meta, $filter );
do_action( 'w2m_import_meta_not_filterable', $filter, $meta_index, $meta );
continue;
}
$value = $filter->filter( $value, $object_id );
Expand Down

0 comments on commit cba6f4b

Please sign in to comment.