Updated SoapServerBuilder

This commit is contained in:
Francis Besset 2011-10-10 00:08:06 +02:00
parent b270a51ba5
commit c1a3059a95
1 changed files with 1 additions and 87 deletions

View File

@ -13,8 +13,6 @@
namespace BeSimple\SoapServer; namespace BeSimple\SoapServer;
use BeSimple\SoapCommon\AbstractSoapBuilder; use BeSimple\SoapCommon\AbstractSoapBuilder;
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
/** /**
* SoapServerBuilder provides a fluent interface to configure and create a SoapServer instance. * SoapServerBuilder provides a fluent interface to configure and create a SoapServer instance.
@ -50,9 +48,6 @@ class SoapServerBuilder extends AbstractSoapBuilder
// TODO: this is not the default, but safer // TODO: this is not the default, but safer
$this->withErrorReporting(false); $this->withErrorReporting(false);
$this->options['classmap'] = array();
$this->options['typemap'] = array();
} }
public function build() public function build()
@ -61,7 +56,7 @@ class SoapServerBuilder extends AbstractSoapBuilder
use_soap_error_handler($this->errorReporting); use_soap_error_handler($this->errorReporting);
$server = new SoapServer($this->wsdl, $this->options); $server = new SoapServer($this->wsdl, $this->getSoapOptions());
$server->setPersistence($this->persistence); $server->setPersistence($this->persistence);
if (null !== $this->handlerClass) { if (null !== $this->handlerClass) {
@ -137,87 +132,6 @@ class SoapServerBuilder extends AbstractSoapBuilder
return $this; return $this;
} }
public function withTypeConverter(TypeConverterInterface $converter)
{
$this->withTypeMapping($converter->getTypeNamespace(), $converter->getTypeName(), array($converter, 'convertXmlToPhp'), array($converter, 'convertPhpToXml'));
return $this;
}
public function withTypeConverters(TypeConverterCollection $converters, $merge = true)
{
$this->withTypemap($converters->getTypemap(), $merge);
return $this;
}
/**
* Adds a type mapping to the typemap.
*
* @param string $xmlNamespace
* @param string $xmlType
* @param callable $fromXmlCallback
* @param callable $toXmlCallback
*/
public function withTypeMapping($xmlNamespace, $xmlType, $fromXmlCallback, $toXmlCallback)
{
$this->options['typemap'][] = array(
'type_ns' => $xmlNamespace,
'type_name' => $xmlType,
'from_xml' => $fromXmlCallback,
'to_xml' => $toXmlCallback
);
return $this;
}
/**
* Sets the typemap.
*
* @param array $typemap The typemap.
* @param boolean $merge If true the given typemap is merged into the existing one, otherwise the existing one is overwritten.
*/
public function withTypemap($typemap, $merge = true)
{
if ($merge) {
$this->options['typemap'] = array_merge($this->options['typemap'], $typemap);
} else {
$this->options['typemap'] = $typemap;
}
return $this;
}
/**
* Adds a class mapping to the classmap.
*
* @param string $xmlType
* @param string $phpType
*/
public function withClassMapping($xmlType, $phpType)
{
$this->options['classmap'][$xmlType] = $phpType;
return $this;
}
/**
* Sets the classmap.
*
* @param array $classmap The classmap.
* @param boolean $merge If true the given classmap is merged into the existing one, otherwise the existing one is overwritten.
*/
public function withClassmap($classmap, $merge = true)
{
if ($merge) {
$this->options['classmap'] = array_merge($this->options['classmap'], $classmap);
} else {
$this->options['classmap'] = $classmap;
}
return $this;
}
protected function validateOptions() protected function validateOptions()
{ {
$this->validateWsdl(); $this->validateWsdl();