1

バンドルには次の構成があります。

    $supportedAdapters = array('curl', 'socket');

    $treeBuilder = new TreeBuilder();
    $rootNode = $treeBuilder->root('example_bundle');
    $rootNode
            ->children()
            ->scalarNode('username')->isRequired()->cannotBeEmpty()->end()
            ->scalarNode('password')->isRequired()->cannotBeEmpty()->end()
            ->scalarNode('adapter')
                ->validate()
                    ->ifNotInArray($supportedAdapters)
                    ->thenInvalid('The adapter %s is not supported. Please choose one of '.json_encode($supportedAdapters))
                ->end()
                ->cannotBeOverwritten()
                ->isRequired()
                ->cannotBeEmpty()
            ->end()
            // allow the use of a proxy for cURL requests
            ->arrayNode('proxy')
                ->children()
                    ->scalarNode('host')->isRequired()->cannotBeEmpty()->end()
                    ->scalarNode('port')->isRequired()->cannotBeEmpty()->end()
                    ->scalarNode('username')->defaultValue(null)->end()
                    ->scalarNode('password')->defaultValue(null)->end()
                ->end()
            ->end();

    return $treeBuilder;

と の 2 つのアダプタがサポートcurlされてsocketいます。

リクエストにはプロキシの使用のみがサポートされていcurlます。構成で、プロキシが設定されていてアダプターがカールしていないかどうかを確認したい場合は、「プロキシで使用するためのカールアダプターのみがサポートされている」ことをユーザーに通知するエラーをスローします。設定値 (この場合はアダプター) を取得し、その値を確認して検証する方法はありますか?

擬似コード:

IF PROXY IS SET AND ADAPTER IS NOT EQUAL TO CURL THEN:
 THROW ERROR ("We don't support the use of a proxy with the socket adapter");
END IF;

これが理にかなっていることを願っています。すべてのドキュメントと API ドキュメントを読みましたが、残念ながら、これを実現するためのオプションが見つかりません。

4

1 に答える 1