Command::generate_items( $args,  $assoc_args )

Generate some items.


Source Source

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

	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.