LLMS_Generator_Courses::generate_courses( array $raw )

Generator called for bulk course imports


Parameters Parameters

$raw

(array) (Required) Raw data array.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-llms-generator-courses.php

	public function generate_courses( $raw ) {

		if ( empty( $raw['courses'] ) ) {
			throw new Exception( esc_attr__( 'Raw data is missing the required "courses" array.', 'lifterlms' ), intval( self::ERROR_GEN_MISSING_REQUIRED ) );
		} elseif ( ! is_array( $raw['courses'] ) ) {
			throw new Exception( esc_attr__( 'The raw "courses" item must be an array.', 'lifterlms' ), intval( self::ERROR_GEN_INVALID_FORMAT ) );
		}

		$courses = array();

		foreach ( $raw['courses'] as $raw_course ) {
			unset( $raw_course['_generator'], $raw_course['_version'] );
			$courses[] = $this->create_course( $raw_course );
		}

		$this->handle_prerequisites();

		return $courses;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Moved from LLMS_Generator to LLMS_Abstract_Generator_Courses.<br> Updated method access from private to public.<br> Throws an exception in favor of returning null when an error is encountered.<br> Returns an array of generated course IDs on success.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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