WordPress\AiClient\Providers

ProviderRegistry::bindModelDependenciespublicWP 0.1.0

Binds dependencies to a model instance.

This method injects required dependencies such as HTTP transporter and authentication into model instances that need them.

Method of the class: ProviderRegistry{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ProviderRegistry = new ProviderRegistry();
$ProviderRegistry->bindModelDependencies( $modelInstance ): void;
$modelInstance(ModelInterface) (required)
The model instance to bind dependencies to.

Changelog

Since 0.1.0 Introduced.

ProviderRegistry::bindModelDependencies() code WP 7.0

public function bindModelDependencies(ModelInterface $modelInstance): void
{
    $className = $this->resolveProviderClassName($modelInstance->providerMetadata()->getId());
    if ($modelInstance instanceof WithHttpTransporterInterface) {
        $modelInstance->setHttpTransporter($this->getHttpTransporter());
    }
    if ($modelInstance instanceof WithRequestAuthenticationInterface) {
        $requestAuthentication = $this->getProviderRequestAuthentication($className);
        if ($requestAuthentication !== null) {
            $modelInstance->setRequestAuthentication($requestAuthentication);
        }
    }
}