Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Components/WebService/Soap/Exceptions/SoapException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
*/
Expand All @@ -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"})
*/
Expand Down Expand Up @@ -115,7 +115,7 @@ public function getRequestHeaders()
*/
public function setRequestHeaders($requestHeaders)
{
$this->requestHeaders = $this->parseHeadersToArray($requestHeaders);
$this->requestHeaders = (object)$this->parseHeadersToArray($requestHeaders);

return $this;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public function getResponseHeaders()
*/
public function setResponseHeaders($responseHeaders)
{
$this->responseHeaders = $this->parseHeadersToArray($responseHeaders);
$this->responseHeaders = (object)$this->parseHeadersToArray($responseHeaders);

return $this;
}
Expand Down
77 changes: 77 additions & 0 deletions Events/StarrayHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Smartbox\Integration\FrameworkBundle\Events;

use Doctrine\Common\Collections\ArrayCollection;
use JMS\Serializer\Context;
use JMS\Serializer\GraphNavigator;
use JMS\Serializer\Handler\SubscribingHandlerInterface;
use JMS\Serializer\VisitorInterface;
use JMS\Serializer\Handler\ArrayCollectionHandler;

class StarrayHandler extends ArrayCollectionHandler
{
/**
* {@inheritdoc}
*/
public static function getSubscribingMethods()
{

return array(
array(
'direction' => 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();
}
}
}
6 changes: 6 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }