Prado\Web\Services\TRpcService::createApiProvider PHP Метод

createApiProvider() публичный Метод

Creates the API provider instance for the current request
public createApiProvider ( TRpcProtocol $protocolHandler, string $providerId )
$protocolHandler TRpcProtocol instance
$providerId string
    public function createApiProvider(TRpcProtocol $protocolHandler, $providerId)
    {
        $_properties = $this->apiProviders[$providerId];
        if (($_providerClass = $_properties->remove('class')) === null) {
            throw new TConfigurationException('rpcservice_apiprovider_required');
        }
        Prado::using($_providerClass);
        $_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass;
        if (!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) {
            throw new TConfigurationException('rpcservice_apiprovider_invalid');
        }
        if (($_rpcServerClass = $_properties->remove('server')) === null) {
            $_rpcServerClass = self::BASE_RPC_SERVER;
        }
        Prado::using($_rpcServerClass);
        $_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass;
        if ($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) {
            throw new TConfigurationException('rpcservice_rpcserver_invalid');
        }
        $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler));
        $_apiProvider->setId($providerId);
        foreach ($_properties as $_key => $_value) {
            $_apiProvider->setSubProperty($_key, $_value);
        }
        return $_apiProvider;
    }