diff --git a/Components/WebService/Soap/Exceptions/SoapException.php b/Components/WebService/Soap/Exceptions/SoapException.php index 04ac1820..414ad1a0 100644 --- a/Components/WebService/Soap/Exceptions/SoapException.php +++ b/Components/WebService/Soap/Exceptions/SoapException.php @@ -23,7 +23,7 @@ class SoapException extends \Exception implements SerializableInterface, Externa /** * @var array * @JMS\Expose - * @JMS\Type("array") + * @JMS\Type("starray") * @JMS\SerializedName("requestHeaders") * @JMS\Groups({"logs"}) */ @@ -41,7 +41,7 @@ class SoapException extends \Exception implements SerializableInterface, Externa /** * @var array * @JMS\Expose - * @JMS\Type("array") + * @JMS\Type("starray") * @JMS\SerializedName("responseHeaders") * @JMS\Groups({"logs"}) */ @@ -115,7 +115,7 @@ public function getRequestHeaders() */ public function setRequestHeaders($requestHeaders) { - $this->requestHeaders = $this->parseHeadersToArray($requestHeaders); + $this->requestHeaders = (object)$this->parseHeadersToArray($requestHeaders); return $this; } @@ -155,7 +155,7 @@ public function getResponseHeaders() */ public function setResponseHeaders($responseHeaders) { - $this->responseHeaders = $this->parseHeadersToArray($responseHeaders); + $this->responseHeaders = (object)$this->parseHeadersToArray($responseHeaders); return $this; } diff --git a/Events/StarrayHandler.php b/Events/StarrayHandler.php new file mode 100644 index 00000000..3b56e806 --- /dev/null +++ b/Events/StarrayHandler.php @@ -0,0 +1,77 @@ + GraphNavigator::DIRECTION_SERIALIZATION, + 'format' => 'json', + 'type' => 'starray', + 'method' => 'serializeToArray', + ), + array( + 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, + 'format' => 'json', + 'type' => 'starray', + 'method' => 'deserializeToArray', + ), + ); + } + + + + /** + * The de-serialization function, which will return always an array. + * This is a temporary solution to a problem. + * + * @param VisitorInterface $visitor + * @param mixed $data + * @param array $type + * @param Context $context + * + * @return array + */ + public function serializeToArray(VisitorInterface $visitor, $data, array $type, Context $context) + { + $data = new ArrayCollection((array)$data); + + return parent::serializeCollection($visitor, $data, $type, $context); + } + + /** + * The de-serialization function, which will return always an array. + * This is a temporary solution to a problem. + * + * @param VisitorInterface $visitor + * @param mixed $data + * @param array $type + * @param Context $context + * + * @return array + */ + public function deserializeToArray(VisitorInterface $visitor, $data, array $type, Context $context) + { + if (is_string($data)) { + return array($data); + } elseif (is_array($data)) { + return $data; + } else { + return array(); + } + } +} diff --git a/Resources/config/services.yml b/Resources/config/services.yml index e3c3f1c0..9503f164 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -24,6 +24,7 @@ parameters: smartesb.steps_provider.dbal.class: Smartbox\Integration\FrameworkBundle\Components\DB\Dbal\DbalStepsProvider smartesb.steps_provider.nosql.class: Smartbox\Integration\FrameworkBundle\Components\DB\NoSQL\NoSQLStepsProvider smartesb.steps_provider.csv.class: Smartbox\Integration\FrameworkBundle\Components\FileService\Csv\CsvConfigurableStepsProvider + smartesb.serialization.handler.starray.class: Smartbox\Integration\FrameworkBundle\Events\StarrayHandler services: smartesb.serialization.handler.mongodate: @@ -108,3 +109,8 @@ services: smartesb.handlers.async: class: '%smartesb.handlers.message_routing.class%' + + smartesb.serialization.handler.starray: + class: '%smartesb.serialization.handler.starray.class%' + tags: + - { name: jms_serializer.subscribing_handler }