SoapOptions cache dir introduced + SoapOptionsBuilder - new methods added
This commit is contained in:
parent
374c64538a
commit
3c0f731086
|
@ -28,16 +28,18 @@ class SoapOptions
|
|||
protected $soapFeatures;
|
||||
protected $wsdlFile;
|
||||
protected $wsdlCacheType;
|
||||
protected $wsdlCacheDir;
|
||||
protected $classMap;
|
||||
protected $typeConverterCollection;
|
||||
protected $attachmentType;
|
||||
|
||||
/**
|
||||
* @param int $soapVersion = SoapOptions::SOAP_VERSION_1_1|SoapOptions::SOAP_VERSION_1_2
|
||||
* @param SoapOptions::SOAP_VERSION_1_1|SoapOptions::SOAP_VERSION_1_2 $soapVersion
|
||||
* @param string $encoding = SoapOptions::SOAP_ENCODING_UTF8
|
||||
* @param SoapFeatures $features
|
||||
* @param string $wsdlFile
|
||||
* @param string $wsdlCacheType = SoapOptions::SOAP_CACHE_TYPE_NONE|SoapOptions::SOAP_CACHE_TYPE_MEMORY|SoapOptions::SOAP_CACHE_TYPE_DISK|SoapOptions::SOAP_CACHE_TYPE_DISK_MEMORY
|
||||
* @param string $wsdlCacheDir = null
|
||||
* @param ClassMap $classMap
|
||||
* @param TypeConverterCollection $typeConverterCollection
|
||||
* @param string $attachmentType = SoapOptions::SOAP_ATTACHMENTS_OFF|SoapOptions::SOAP_ATTACHMENTS_TYPE_SWA|SoapOptions::ATTACHMENTS_TYPE_MTOM|SoapOptions::ATTACHMENTS_TYPE_BASE64
|
||||
|
@ -48,6 +50,7 @@ class SoapOptions
|
|||
SoapFeatures $features,
|
||||
$wsdlFile,
|
||||
$wsdlCacheType,
|
||||
$wsdlCacheDir = null,
|
||||
ClassMap $classMap,
|
||||
TypeConverterCollection $typeConverterCollection,
|
||||
$attachmentType = null
|
||||
|
@ -77,6 +80,16 @@ class SoapOptions
|
|||
return $this->wsdlFile;
|
||||
}
|
||||
|
||||
public function hasWsdlCacheDir()
|
||||
{
|
||||
return $this->wsdlCacheDir !== null;
|
||||
}
|
||||
|
||||
public function getWsdlCacheDir()
|
||||
{
|
||||
return $this->wsdlCacheDir;
|
||||
}
|
||||
|
||||
public function getWsdlCacheType()
|
||||
{
|
||||
return $this->wsdlCacheType;
|
||||
|
@ -118,6 +131,9 @@ class SoapOptions
|
|||
'classmap' => $this->getClassMap()->getAll(),
|
||||
'typemap' => $this->getTypeConverterCollection()->getTypemap(),
|
||||
];
|
||||
if ($this->hasWsdlCacheDir()) {
|
||||
$optionsAsArray['wsdl_cache_dir'] = $this->getWsdlCacheDir();
|
||||
}
|
||||
|
||||
return $optionsAsArray;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,37 @@ use InvalidArgumentException;
|
|||
*/
|
||||
class SoapOptionsBuilder
|
||||
{
|
||||
static public function createWithDefaults($wsdlFile, $wsdlCacheType = Cache::TYPE_NONE)
|
||||
{
|
||||
static public function createWithDefaults(
|
||||
$wsdlFile,
|
||||
$wsdlCacheType = SoapOptions::SOAP_CACHE_TYPE_NONE,
|
||||
$wsdlCacheDir = null
|
||||
) {
|
||||
return self::createWithClassMap($wsdlFile, new ClassMap(), $wsdlCacheType, $wsdlCacheDir);
|
||||
}
|
||||
|
||||
static public function createSwaWithClassMap(
|
||||
$wsdlFile,
|
||||
ClassMap $classMap,
|
||||
$wsdlCacheType = SoapOptions::SOAP_CACHE_TYPE_NONE,
|
||||
$wsdlCacheDir = null
|
||||
) {
|
||||
return self::createWithClassMap($wsdlFile, $classMap, $wsdlCacheType, $wsdlCacheDir, SoapOptions::SOAP_ATTACHMENTS_TYPE_SWA);
|
||||
}
|
||||
|
||||
static public function createWithClassMap(
|
||||
$wsdlFile,
|
||||
ClassMap $classMap,
|
||||
$wsdlCacheType = SoapOptions::SOAP_CACHE_TYPE_NONE,
|
||||
$wsdlCacheDir = null,
|
||||
$attachmentType = null
|
||||
) {
|
||||
if (!Cache::hasType($wsdlCacheType)) {
|
||||
throw new InvalidArgumentException;
|
||||
throw new InvalidArgumentException('Invalid cache type');
|
||||
}
|
||||
if ($wsdlCacheType !== SoapOptions::SOAP_CACHE_TYPE_NONE) {
|
||||
if ($wsdlCacheDir === null) {
|
||||
throw new InvalidArgumentException('Cache dir must be set for this wsdl cache type');
|
||||
}
|
||||
}
|
||||
$soapOptions = new SoapOptions(
|
||||
SoapOptions::SOAP_VERSION_1_2,
|
||||
|
@ -35,8 +62,10 @@ class SoapOptionsBuilder
|
|||
]),
|
||||
$wsdlFile,
|
||||
$wsdlCacheType,
|
||||
new ClassMap(),
|
||||
new TypeConverterCollection()
|
||||
$wsdlCacheDir,
|
||||
$classMap,
|
||||
new TypeConverterCollection(),
|
||||
$attachmentType
|
||||
);
|
||||
|
||||
return $soapOptions;
|
||||
|
|
Loading…
Reference in New Issue