WP_CLI\Iterators
Transform{}
Applies one or more callbacks to an item before returning it.
Хуков нет.
Использование
$Transform = new Transform(); // use class methods
Методы
- public add_transform( $fn )
- public current()
Код Transform{} Transform{} WP-CLI 2.8.0-alpha
class Transform extends IteratorIterator { private $transformers = []; public function add_transform( $fn ) { $this->transformers[] = $fn; } public function current() { $value = parent::current(); foreach ( $this->transformers as $fn ) { $value = call_user_func( $fn, $value ); } return $value; } }