WordPress\AiClient\Providers

ProviderRegistry::setHttpTransporterForProviderprivateWP 0.1.0

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

Метод класса: ProviderRegistry{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->setHttpTransporterForProvider( $className, $httpTransporter ): void;
$className(class-string) (обязательный)
The provider class name.
$httpTransporter(HttpTransporterInterface) (обязательный)
The HTTP transporter instance.

Список изменений

С версии 0.1.0 Введена.

Код ProviderRegistry::setHttpTransporterForProvider() 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);
        }
    }
}