WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\Utils

BlockTemplateUtils::gutenberg_flatten_blocks() public WC 1.0

Returns an array containing the references of the passed blocks and their inner blocks.

{} It's a method of the class: BlockTemplateUtils{}

No Hooks.

Return

Array. block references to the passed blocks and their inner blocks.

Usage

$result = BlockTemplateUtils::gutenberg_flatten_blocks( $blocks );
$blocks(array) (required) (passed by reference — &)
array of blocks.

Code of BlockTemplateUtils::gutenberg_flatten_blocks() WC 6.1.0

public static function gutenberg_flatten_blocks( &$blocks ) {
	$all_blocks = array();
	$queue      = array();
	foreach ( $blocks as &$block ) {
		$queue[] = &$block;
	}
	$queue_count = count( $queue );

	while ( $queue_count > 0 ) {
		$block = &$queue[0];
		array_shift( $queue );
		$all_blocks[] = &$block;

		if ( ! empty( $block['innerBlocks'] ) ) {
			foreach ( $block['innerBlocks'] as &$inner_block ) {
				$queue[] = &$inner_block;
			}
		}

		$queue_count = count( $queue );
	}

	return $all_blocks;
}