WC_Autoloader::load_rest_v4_controller_recursivelyprivateWC 1.0

Recursively load REST API V4 controllers from subdirectories.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->load_rest_v4_controller_recursively( $file ): bool;
$file(строка) (обязательный)
File name to search for.

Код WC_Autoloader::load_rest_v4_controller_recursively() WC 10.5.2

private function load_rest_v4_controller_recursively( $file ): bool {
	$v4_base_path = $this->include_path . 'rest-api/Controllers/Version4/';

	// Use RecursiveDirectoryIterator to search subdirectories.
	if ( is_dir( $v4_base_path ) ) {
		$iterator = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $v4_base_path, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::SELF_FIRST
		);

		foreach ( $iterator as $dir_info ) {
			if ( $dir_info->isDir() ) {
				$subdir_path = $dir_info->getPathname() . '/';
				if ( $this->load_file( $subdir_path . $file ) ) {
					return true;
				}
			}
		}
	}
	return false;
}