Automattic\WooCommerce\Blocks\Assets
AssetDataRegistry::hydrate_data_from_api_request
Hydrate some data from the API.
Метод класса: AssetDataRegistry{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$AssetDataRegistry = new AssetDataRegistry(); $AssetDataRegistry->hydrate_data_from_api_request( $key, $path, $check_key_exists );
- $key(строка) (обязательный)
- The key used to reference the data being registered.
- $path(строка) (обязательный)
- REST API path to preload.
- $check_key_exists(true|false)
- Deprecated. Duplicate data will be ignored if the key exists.
По умолчанию:false
Код AssetDataRegistry::hydrate_data_from_api_request() AssetDataRegistry::hydrate data from api request WC 11.0.1
public function hydrate_data_from_api_request( $key, $path, $check_key_exists = false ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- Deprecated parameter kept for backwards compatibility.
if ( 3 <= func_num_args() ) {
wc_deprecated_argument(
__METHOD__ . '()',
'8.9',
'The $check_key_exists parameter is no longer used: all duplicate data will be ignored if the key exists by default'
);
}
$this->add(
$key,
function () use ( $path ) {
if ( isset( $this->preloaded_api_requests[ $path ], $this->preloaded_api_requests[ $path ]['body'] ) ) {
return $this->preloaded_api_requests[ $path ]['body'];
}
$response = Package::container()->get( Hydration::class )->get_rest_api_response_data( $path );
return $response['body'] ?? '';
}
);
}