Skip to content

Commit

Permalink
disp
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Jan 3, 2021
1 parent dba7cdf commit d89126f
Show file tree
Hide file tree
Showing 20 changed files with 632 additions and 410 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"require": {
"php": "^7.2",
"rybakit/arguments-resolver": "^0.5.0",
"ext-simplexml": "*",
"doctrine/instantiator": "^1.0.3",
"goetas-webservices/xsd2php-runtime": "^0.2.11",
"jms/serializer": "^3.0"
Expand Down
41 changes: 9 additions & 32 deletions src/Arguments/ArgumentsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace GoetasWebservices\SoapServices\Metadata\Arguments;

use Doctrine\Instantiator\Instantiator;
use GoetasWebservices\SoapServices\Metadata\Arguments\Headers\Header;
use GoetasWebservices\SoapServices\Metadata\SerializerUtils;
use JMS\Serializer\Accessor\DefaultAccessorStrategy;
use JMS\Serializer\DeserializationContext;
Expand All @@ -30,21 +29,24 @@ public function __construct(Serializer $serializer)
*/
public function readArguments(array $args, array $message): object
{
$envelope = array_filter($args, static function ($item) use ($message) {
$envelopes = array_filter($args, static function ($item) use ($message) {
return $item instanceof $message['message_fqcn'];
});
if ($envelope) {
return reset($envelope);
if ($envelopes) {
$envelope = reset($envelopes);
$this->handleHeaders($args, $message, $envelope);

return $envelope;
}

$instantiator = new Instantiator();
$envelope = $instantiator->instantiate($message['message_fqcn']);
$this->handleHeaders($args, $message, $envelope);

if (!count($message['parts'])) {
return $envelope;
}

$args = $this->handleHeaders($args, $message, $envelope);
if ($args[0] instanceof $message['part_fqcn']) {
$envelope->setBody($args[0]);

Expand Down Expand Up @@ -99,40 +101,15 @@ public function readArguments(array $args, array $message): object
/**
* @param array $args
* @param array $message
*
* @return array
*/
private function handleHeaders(array $args, array $message, object $envelope): array
private function handleHeaders(array $args, array $message, object $envelope): void
{
$headers = array_filter($args, static function ($item) use ($message) {
return $item instanceof $message['headers_fqcn'];
});
if ($headers) {
if (count($headers)) {
$envelope->setHeader(reset($headers));
} else {
$headers = array_filter($args, static function ($item) {
return $item instanceof Header;
});
if (count($headers)) {
$factory = SerializerUtils::getMetadataFactory($this->serializer);
$classMetadata = $factory->getMetadataForClass($message['message_fqcn']);
$propertyMetadata = $classMetadata->propertyMetadata['header'];

$instantiator = new Instantiator();
$header = $instantiator->instantiate($propertyMetadata->type['name']);
foreach ($headers as $headerInfo) {
$header->addHeader($headerInfo);
}

$envelope->setHeader($header);
}
}

$args = array_filter($args, static function ($item) use ($message) {
return !($item instanceof Header) && !($item instanceof $message['headers_fqcn']);
});

return $args;
}

/**
Expand Down
30 changes: 0 additions & 30 deletions src/Arguments/Headers/Handler/FaultHandler.php

This file was deleted.

139 changes: 0 additions & 139 deletions src/Arguments/Headers/Handler/HeaderHandler.php

This file was deleted.

20 changes: 0 additions & 20 deletions src/Arguments/Headers/Handler/HeaderPlaceholder.php

This file was deleted.

60 changes: 0 additions & 60 deletions src/Arguments/Headers/HeaderBag.php

This file was deleted.

Loading

0 comments on commit d89126f

Please sign in to comment.