WordPress\AiClient\Providers

ProviderRegistry::setHttpTransporterForProviderprivateWP 0.1.0

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

Method of the class: ProviderRegistry{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->setHttpTransporterForProvider( $className, $httpTransporter ): void;
$className(class-string) (required)
The provider class name.
$httpTransporter(HttpTransporterInterface) (required)
The HTTP transporter instance.

Changelog

Since 0.1.0 Introduced.

ProviderRegistry::setHttpTransporterForProvider() code WP 7.0

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);
        }
    }
}