ProviderRegistry::setHttpTransporterForProvider( WordPressAiClientProvidersclass-string $className, WordPressAiClientProvidersHttpContractsHttpTransporterInterface $httpTransporter )

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Sets the HTTP transporter for a specific provider, hooking up its class instances.

Parameters

$className<span class="WordPressAiClientProvidersclass-string”>WordPressAiClientProvidersclass-stringrequired
The provider class name.
$httpTransporterWordPressAiClientProvidersHttpContractsHttpTransporterInterfacerequired
The HTTP transporter instance.

Source

private function setHttpTransporterForProvider(string $className, HttpTransporterInterface $httpTransporter): void
{
    $availability = $className::availability();
    if ($availability instanceof WithHttpTransporterInterface) {
        $availability->setHttpTransporter($httpTransporter);
    }
    $modelMetadataDirectory = $className::modelMetadataDirectory();
    if ($modelMetadataDirectory instanceof WithHttpTransporterInterface) {
        $modelMetadataDirectory->setHttpTransporter($httpTransporter);
    }
    if (is_subclass_of($className, ProviderWithOperationsHandlerInterface::class)) {
        $operationsHandler = $className::operationsHandler();
        if ($operationsHandler instanceof WithHttpTransporterInterface) {
            $operationsHandler->setHttpTransporter($httpTransporter);
        }
    }
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.