Automattic\WooCommerce\Internal\PushNotifications\Services

StepLogQuery::split_line_into_token_rows │ private static │ WC 1.0

Splits one stored line into a row per token it names, so a per-token read sees the same shape it would have seen when every token had a line of its own.

Метод класса: StepLogQuery{}

Хуков нет.

Возвращает

array[]. A row per token named, which may be none.

Использование

$result = StepLogQuery::split_line_into_token_rows( $row, $token_ids ): array;
$row(массив) (обязательный)
The stored row.
$token_ids(int[]) (обязательный)
The tokens being asked about.

Код StepLogQuery::split_line_into_token_rows() WC 11.3.0

private static function split_line_into_token_rows( array $row, array $token_ids ): array {
	$context = $row['context'] ?? array();
	$rows    = array();

	foreach ( $token_ids as $token_id ) {
		$token_id = (int) $token_id;

		foreach ( (array) ( $context['excluded_tokens'] ?? array() ) as $reason => $excluded ) {
			if ( in_array( $token_id, array_map( 'intval', (array) $excluded ), true ) ) {
				$rows[] = self::strip_unrelated_tokens( $row, $token_id, 'token_excluded', (string) $reason );
				continue 2;
			}
		}

		if ( in_array( $token_id, array_map( 'intval', (array) ( $context['invalid_token_ids'] ?? array() ) ), true ) ) {
			$rows[] = self::strip_unrelated_tokens( $row, $token_id, 'dispatched', 'invalid_token' );
			continue;
		}

		if ( in_array( $token_id, array_map( 'intval', (array) ( $context['token_ids'] ?? array() ) ), true ) ) {
			$rows[] = self::strip_unrelated_tokens( $row, $token_id, 'token_included', 'ok' );
		}
	}

	return $rows;
}