Automattic\WooCommerce\Internal\Admin\Logging\FileV2
FileController::get_files_by_id
Get one or more File instances from an array of file IDs.
Method of the class: FileController{}
No Hooks.
Returns
File[].
Usage
$FileController = new FileController(); $FileController->get_files_by_id( $file_ids ): array;
- $file_ids(array) (required)
- An array of file IDs (file basename without the hash).
FileController::get_files_by_id() FileController::get files by id code WC 10.8.1
public function get_files_by_id( array $file_ids ): array {
$log_directory = Settings::get_log_directory();
$paths = array();
foreach ( $file_ids as $file_id ) {
// Look for the standard filename format first, which includes a hash.
$glob = glob( $log_directory . $file_id . '-*.log' );
if ( ! $glob ) {
$glob = glob( $log_directory . $file_id . '.log' );
}
if ( is_array( $glob ) ) {
$paths = array_merge( $paths, $glob );
}
}
$files = $this->convert_paths_to_objects( array_unique( $paths ) );
return $files;
}