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)
- If set to true, duplicate data will be ignored if the key exists. If false, duplicate data will cause an exception.
По умолчанию: false
Код AssetDataRegistry::hydrate_data_from_api_request() AssetDataRegistry::hydrate data from api request WC 9.8.5
public function hydrate_data_from_api_request( $key, $path, $check_key_exists = false ) { $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'] ?? ''; }, $check_key_exists ); }