From 2d36e5f06002e11e8be346f8518d79c22abd3856 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Tue, 2 Apr 2019 14:58:41 +0200 Subject: [PATCH] Fix compatibility with SF4 + Other fixes --- src/BeSimple/SoapBundle/.gitignore | 1 + .../Controller/SoapWebServiceController.php | 28 +++++++------------ .../BeSimpleSoapExtension.php | 1 + .../SoapBundle/Handler/ExceptionHandler.php | 2 +- .../Resources/config/webservice.xml | 2 +- .../Annotation/ComplexType.php | 14 ++++++++-- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 10 +++---- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/BeSimple/SoapBundle/.gitignore b/src/BeSimple/SoapBundle/.gitignore index c49a5d8..a934131 100644 --- a/src/BeSimple/SoapBundle/.gitignore +++ b/src/BeSimple/SoapBundle/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock phpunit.xml +.idea/ diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index b7232c2..6c412e9 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -15,12 +15,14 @@ namespace BeSimple\SoapBundle\Controller; use BeSimple\SoapBundle\Handler\ExceptionHandler; use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapResponse; +use BeSimple\SoapBundle\WebServiceContext; use BeSimple\SoapServer\SoapServerBuilder; use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\FlattenException; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -31,11 +33,7 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; */ class SoapWebServiceController implements ContainerAwareInterface { - - /** - * @var ContainerInterface - */ - protected $container; + use ContainerAwareTrait; /** * @var \SoapServer @@ -62,19 +60,12 @@ class SoapWebServiceController implements ContainerAwareInterface */ private $headers = array(); - /** - * {@inheritDoc} - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } - /** * @return \BeSimple\SoapBundle\Soap\SoapResponse */ public function callAction($webservice) { + /** @var WebServiceContext $webServiceContext */ $webServiceContext = $this->getWebServiceContext($webservice); $this->serviceBinder = $webServiceContext->getServiceBinder(); @@ -98,7 +89,7 @@ class SoapWebServiceController implements ContainerAwareInterface } /** - * @return Symfony\Component\HttpFoundation\Response + * @return Response */ public function definitionAction($webservice) { @@ -110,7 +101,8 @@ class SoapWebServiceController implements ContainerAwareInterface ) )); - $request = $this->container->get('request'); + /** @var Request $request */ + $request = $this->container->get('request_stack')->getCurrentRequest(); $query = $request->query; if ($query->has('wsdl') || $query->has('WSDL')) { $request->setRequestFormat('wsdl'); @@ -136,9 +128,9 @@ class SoapWebServiceController implements ContainerAwareInterface throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e); } - $view = 'TwigBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig'; + $view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig'; $code = $exception->getStatusCode(); - $details = $this->container->get('templating')->render($view, array( + $details = $this->container->get('twig')->render($view, array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, diff --git a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php index 8a947cb..69f8908 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php @@ -177,6 +177,7 @@ class BeSimpleSoapExtension extends Extension $options = $container ->getDefinition('besimple.soap.context.'.$bindingSuffix) + ->setPublic(true) ->getArgument(2); $definition->replaceArgument(2, array_merge($options, $config)); diff --git a/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php b/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php index 54c12b4..2a2d613 100644 --- a/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php +++ b/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php @@ -13,8 +13,8 @@ namespace BeSimple\SoapBundle\Handler; use BeSimple\SoapServer\Exception\ReceiverSoapFault; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\FlattenException; /** * @author Francis Besset diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index 343885c..23de8cf 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -19,7 +19,7 @@ - + diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php index 47f9019..d3d2a78 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php @@ -35,6 +35,11 @@ class ComplexType extends Configuration return $this->isNillable; } + public function getIsNillable() + { + return $this->isNillable; + } + public function setName($name) { $this->name = $name; @@ -50,6 +55,11 @@ class ComplexType extends Configuration $this->isNillable = (bool) $isNillable; } + public function setIsNillable($isNillable) + { + $this->isNillable = (bool) $isNillable; + } + /** * @return bool */ @@ -66,7 +76,7 @@ class ComplexType extends Configuration public function setIsAttribute($isAttribute) { $this->isAttribute = $isAttribute; - + return $this; } @@ -74,4 +84,4 @@ class ComplexType extends Configuration { return 'complextype'; } -} \ No newline at end of file +} diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index ff66351..4280eee 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -238,7 +238,7 @@ class Dumper $complexType = $this->document->createElement(static::XSD_NS.':complexType'); $complexType->setAttribute('name', $type->getXmlType()); - $all = $this->document->createElement(static::XSD_NS.':'.'sequence'); + $all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); $complexType->appendChild($all); foreach ($type->all() as $child) { @@ -258,10 +258,10 @@ class Dumper $name = $childType->getName(); } - if (0 === strpos($name, 'ArrayOf')) { - $isArray = true; - $name = lcfirst(substr($name, 7)); - } +// if (0 === strpos($name, 'ArrayOf')) { +// $isArray = true; +// $name = lcfirst(substr($name, 7)); +// } $element->setAttribute('type', static::TYPES_NS.':'.$name); } else {