ProviderRegistry::bindModelDependencies( WordPressAiClientProvidersModelsContractsModelInterface $modelInstance ): void

Binds dependencies to a model instance.

Description

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

Parameters

$modelInstanceWordPressAiClientProvidersModelsContractsModelInterfacerequired
The model instance to bind dependencies to.

Return

void

Source

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

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

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