Automattic\WooCommerce\Internal\Admin\Logging\FileV2

FileController::rotate_file()privateWC 1.0

Get all the rotations of a file and increment them, so that they overwrite the previous file with that rotation.

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

Хуков нет.

Возвращает

true|false. True if the file and all its rotations were successfully rotated.

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

// private - только в коде основоного (родительского) класса
$result = $this->rotate_file( $file_id ): bool;
$file_id(строка) (обязательный)
A file ID (file basename without the hash).

Код FileController::rotate_file() WC 9.5.1

private function rotate_file( $file_id ): bool {
	$rotations = $this->get_file_rotations( $file_id );

	if ( is_wp_error( $rotations ) || ! isset( $rotations['current'] ) ) {
		return false;
	}

	$max_rotation_marker = self::MAX_FILE_ROTATIONS - 1;

	// Don't rotate a file with the maximum rotation.
	unset( $rotations[ $max_rotation_marker ] );

	$results = array();
	// Rotate starting with oldest first and working backwards.
	for ( $i = $max_rotation_marker; $i >= 0; $i -- ) {
		if ( isset( $rotations[ $i ] ) ) {
			$results[] = $rotations[ $i ]->rotate();
		}
	}
	$results[] = $rotations['current']->rotate();

	return ! in_array( false, $results, true );
}