Submission_Export::get_rows( awsmug\Torro_Forms\DB_Objects\Submissions\Submission_Collection $submissions, array $submission_columns, array $element_columns )

Gets all rows for the export.

Description

Parameters

$submissions

(awsmug\Torro_Forms\DB_Objects\Submissions\Submission_Collection) (Required) Submissions to create rows for.

$submission_columns

(array) (Required) Submission columns definition.

$element_columns

(array) (Required) Element columns definition for submission values.

Return

(array) Rows array where each row is an associative array of <code>$column_slug => $column_value</code> pairs.

Source

File: src/components/submission-export.php

	protected function get_rows( $submissions, $submission_columns, $element_columns ) {
		$rows = array();

		foreach ( $submissions as $submission ) {
			$row = array();

			foreach ( $submission_columns as $slug => $data ) {
				$row[ $slug ] = call_user_func( $data['callback'], $submission );
			}

			$element_values = $submission->get_element_values_data();

			foreach ( $element_columns as $element_id => $data ) {
				$values = isset( $element_values[ $element_id ] ) ? $element_values[ $element_id ] : array();

				$column_values = call_user_func( $data['callback'], $values );
				foreach ( $data['columns'] as $slug => $label ) {
					$row[ $slug ] = $column_values[ $slug ];
				}
			}

			$rows[] = $row;
		}

		return $rows;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.