Automattic\WooCommerce\Internal\PushNotifications\Services
DriverAvailabilityService::query_jetpack_connection
Runs the given check against the Jetpack connection manager, returning false (and logging) if the connection state can't be determined.
A failure is recorded against $check_key on {@see self::$failed_checks} as well as returning false, so the driver that depends on this check can tell an unconnected store from one whose connection state could not be read.
Deliberately not memoized. The container hands out one shared instance of this service, so a cached result would outlive the caller that asked for it and go stale in any long-lived process (WP-CLI, cron), where the Jetpack connection can change under it.
Метод класса: DriverAvailabilityService{}
Хуков нет.
Возвращает
bool.
Использование
// private - только в коде основоного (родительского) класса $result = $this->query_jetpack_connection( $check_key, $check ): bool;
- $check_key(строка) (обязательный)
- Identifies the check, so a failure is recorded against the driver that depends on it.
- $check(callable) (обязательный)
- .
Код DriverAvailabilityService::query_jetpack_connection() DriverAvailabilityService::query jetpack connection WC 11.2.2
private function query_jetpack_connection( string $check_key, callable $check ): bool {
// Resolved before the try so the catch below cannot re-run the call that
// threw, which would escape uncaught.
$proxy = wc_get_container()->get( LegacyProxy::class );
try {
if ( ! class_exists( JetpackConnectionManager::class ) ) {
return false;
}
return $check( $proxy->get_instance_of( JetpackConnectionManager::class ) );
} catch ( Throwable $e ) {
$this->failed_checks[ $check_key ] = true;
$this->log_throwable( 'Error determining Jetpack connection state for push notifications', $e, $proxy );
return false;
}
}