Command::generate_items( $args,  $assoc_args )

Generate some items.


Source Source

File: libraries/lifterlms-cli/src/Commands/Restful/Command.php

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
public function generate_items( $args, $assoc_args ) {
 
    $count = $assoc_args['count'];
    unset( $assoc_args['count'] );
    $format = $assoc_args['format'];
    unset( $assoc_args['format'] );
 
    $notify = false;
    if ( 'progress' === $format ) {
        $notify = \WP_CLI\Utils\make_progress_bar( 'Generating items', $count );
    }
 
    for ( $i = 0; $i < $count; $i++ ) {
 
        list( $status, $body ) = $this->do_request( 'POST', $this->get_base_route(), $assoc_args );
 
        if ( 'progress' === $format ) {
            $notify->tick();
        } elseif ( 'ids' === $format ) {
            echo $body['id'];
            if ( $i < $count - 1 ) {
                echo ' ';
            }
        }
    }
 
    if ( 'progress' === $format ) {
        $notify->finish();
    }
}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.