Automattic\WooCommerce\Blocks\BlockTypes

AbstractBlock::get_chunks_paths()protectedWC 1.0

Generate an array of chunks paths for loading translation.

Method of the class: AbstractBlock{}

No Hooks.

Return

String[]. $chunks list of chunks to load.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_chunks_paths( $chunks_folder );
$chunks_folder(string) (required)
The folder to iterate over.

AbstractBlock::get_chunks_paths() code WC 9.4.2

protected function get_chunks_paths( $chunks_folder ) {
	$build_path = \Automattic\WooCommerce\Blocks\Package::get_path() . 'assets/client/blocks/';
	$blocks     = [];
	if ( ! is_dir( $build_path . $chunks_folder ) ) {
		return [];
	}
	foreach ( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $build_path . $chunks_folder, \FilesystemIterator::UNIX_PATHS ) ) as $block_name ) {
		$blocks[] = str_replace( $build_path, '', $block_name );
	}

	$chunks = preg_filter( '/.js/', '', $blocks );
	return $chunks;
}