[SoapBundle] Added configuration to configure client proxy
This commit is contained in:
parent
1a7f60b679
commit
7a9119cef1
@ -98,6 +98,23 @@ class BeSimpleSoapExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
$proxy = $options['proxy'];
|
||||
if (false !== $proxy['host']) {
|
||||
if (null !== $proxy['auth']) {
|
||||
if ('basic' === $proxy['auth']) {
|
||||
$proxy['auth'] = \CURLAUTH_BASIC;
|
||||
} elseif ('ntlm' === $proxy['auth']) {
|
||||
$proxy['auth'] = \CURLAUTH_NTLM;
|
||||
}
|
||||
}
|
||||
|
||||
$definition->addMethodCall('withProxy', array(
|
||||
$proxy['host'], $proxy['port'],
|
||||
$proxy['login'], $proxy['password'],
|
||||
$proxy['auth']
|
||||
));
|
||||
}
|
||||
|
||||
if (isset($defOptions['cache_type'])) {
|
||||
$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
class Configuration
|
||||
{
|
||||
private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory');
|
||||
private $proxyAuth = array('basic', 'ntlm');
|
||||
|
||||
/**
|
||||
* Generates the configuration tree.
|
||||
@ -85,12 +86,33 @@ class Configuration
|
||||
->scalarNode('cache_type')
|
||||
->validate()
|
||||
->ifNotInArray($this->cacheTypes)
|
||||
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
|
||||
->thenInvalid(sprintf('The cache type has to be either: %s', implode(', ', $this->cacheTypes)))
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('classmap')
|
||||
->useAttributeAsKey('name')->prototype('scalar')->end()
|
||||
->end()
|
||||
->arrayNode('proxy')
|
||||
->info('proxy configuration')
|
||||
->addDefaultsIfNotSet()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !is_array($v); })
|
||||
->then(function ($v) { return array('host' => null === $v ? false : $v); })
|
||||
->end()
|
||||
->children()
|
||||
->scalarNode('host')->defaultFalse()->end()
|
||||
->scalarNode('port')->defaultValue(3128)->end()
|
||||
->scalarNode('login')->defaultNull()->end()
|
||||
->scalarNode('password')->defaultNull()->end()
|
||||
->scalarNode('auth')
|
||||
->defaultNull()
|
||||
->validate()
|
||||
->ifNotInArray($this->proxyAuth)
|
||||
->thenInvalid(sprintf('The proxy auth has to be either: %s', implode(', ', $this->proxyAuth)))
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -1,8 +1,8 @@
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Minimal client configuration
|
||||
----------------------------
|
||||
Client configuration
|
||||
--------------------
|
||||
|
||||
Configure your first client in your config file:
|
||||
|
||||
@ -12,8 +12,20 @@ Configure your first client in your config file:
|
||||
be_simple_soap:
|
||||
clients:
|
||||
DemoApi:
|
||||
wsdl: http://localhost:8086/app_dev.php/ws/DemoApi?wsdl
|
||||
# required
|
||||
wsdl: http://localhost/app_dev.php/ws/DemoApi?wsdl
|
||||
|
||||
# classmap (optional)
|
||||
classmap:
|
||||
type_name: "Full\Class\Name"
|
||||
|
||||
# proxy (optional)
|
||||
proxy:
|
||||
host: proxy.domain.name # required to enable proxy configuration
|
||||
port: 3128
|
||||
login: ~
|
||||
password: ~
|
||||
auth: ~ # can be 'basic' or 'ntlm'
|
||||
|
||||
Using client
|
||||
------------
|
||||
|
Loading…
Reference in New Issue
Block a user