WordPress\AiClient\Providers
ProviderRegistry::bindModelDependencies
Binds dependencies to a model instance.
This method injects required dependencies such as HTTP transporter and authentication into model instances that need them.
Метод класса: ProviderRegistry{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$ProviderRegistry = new ProviderRegistry(); $ProviderRegistry->bindModelDependencies( $modelInstance ): void;
- $modelInstance(ModelInterface) (обязательный)
- The model instance to bind dependencies to.
Список изменений
| С версии 0.1.0 | Введена. |
Код ProviderRegistry::bindModelDependencies() ProviderRegistry::bindModelDependencies 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);
}
}
}