Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Sf3 #92

Open
wants to merge 4 commits into
base: 0.2
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"ext-soap": "*",
"ext-curl": "*",
"ass/xmlsecurity": "~1.0",
"symfony/framework-bundle": "~2.0|~3.0",
"symfony/twig-bundle": "~2.0|~3.0",
"symfony/framework-bundle": "~3.1",
"symfony/twig-bundle": "~3.1",
"zendframework/zend-mime": "2.1.*"
},
"replace": {
Expand All @@ -39,7 +39,7 @@
"ext-mcrypt": "*",
"mikey179/vfsStream": "~1.0",
"symfony/filesystem": "~2.0",
"symfony/process": "~2.3"
"symfony/process": "~3.1"
},
"autoload": {
"psr-0": { "BeSimple\\": "src/" }
Expand Down
2 changes: 1 addition & 1 deletion src/BeSimple/SoapBundle/BeSimpleSoapBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

namespace BeSimple\SoapBundle;

use BeSimple\SoapBundle\DependencyInjection\Compiler\WebServiceResolverPass;
use BeSimple\SoapBundle\DependencyInjection\Compiler\TypeConverterPass;
use BeSimple\SoapBundle\DependencyInjection\Compiler\WebServiceResolverPass;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand Down
48 changes: 25 additions & 23 deletions src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use BeSimple\SoapBundle\Soap\SoapRequest;
use BeSimple\SoapBundle\Soap\SoapResponse;
use BeSimple\SoapServer\SoapServerBuilder;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand All @@ -28,8 +30,10 @@
* @author Christian Kerl <[email protected]>
* @author Francis Besset <[email protected]>
*/
class SoapWebServiceController extends ContainerAware
class SoapWebServiceController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @var \SoapServer
*/
Expand Down Expand Up @@ -60,17 +64,16 @@ class SoapWebServiceController extends ContainerAware
*/
public function callAction($webservice)
{
$webServiceContext = $this->getWebServiceContext($webservice);
$webServiceContext = $this->getWebServiceContext($webservice);

$this->serviceBinder = $webServiceContext->getServiceBinder();

$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
$this->soapServer = $webServiceContext
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest());
$this->soapServer = $webServiceContext
->getServerBuilder()
->withSoapVersion11()
->withHandler($this)
->build()
;
->build();

ob_start();
$this->soapServer->handle($this->soapRequest->getSoapMessage());
Expand All @@ -94,8 +97,8 @@ public function definitionAction($webservice)
true
)
));

$request = $this->container->get('request');
$request = $this->container->get('request_stack')->getCurrentRequest();
$query = $request->query;
if ($query->has('wsdl') || $query->has('WSDL')) {
$request->setRequestFormat('wsdl');
Expand All @@ -107,9 +110,9 @@ public function definitionAction($webservice)
/**
* Converts an Exception to a SoapFault Response.
*
* @param Request $request The request
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param Request $request The request
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
*
* @return Response
*
Expand All @@ -121,13 +124,13 @@ public function exceptionAction(Request $request, FlattenException $exception, D
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 = 'TwigBundle:Exception:' . ($this->container->get('kernel')->isDebug() ? 'exception' : 'error') . '.txt.twig';
$code = $exception->getStatusCode();
$details = $this->container->get('templating')->render($view, array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'exception' => $exception,
'logger' => $logger,
));

$handler = new ExceptionHandler($exception, $details);
Expand All @@ -139,19 +142,18 @@ public function exceptionAction(Request $request, FlattenException $exception, D
}

$server = SoapServerBuilder::createWithDefaults()
->withWsdl(__DIR__.'/../Handler/wsdl/exception.wsdl')
->withWsdl(__DIR__ . '/../Handler/wsdl/exception.wsdl')
->withWsdlCacheNone()
->withHandler($handler)
->build()
;
->build();

ob_start();
$server->handle(
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://besim.pl/soap/exception/1.0/">'.
'<soapenv:Header/>'.
'<soapenv:Body>'.
'<ns:exception />'.
'</soapenv:Body>'.
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://besim.pl/soap/exception/1.0/">' .
'<soapenv:Header/>' .
'<soapenv:Body>' .
'<ns:exception />' .
'</soapenv:Body>' .
'</soapenv:Envelope>'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Kernel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace BeSimple\SoapBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Adds tagged besimple.soap.converter services to besimple.soap.converter.repository service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace BeSimple\SoapBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Adds tagged besimple.soap.definition.loader services to ebservice.definition.resolver service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="_webservice_call" pattern="/{webservice}">
<route id="_webservice_call" path="/{webservice}" methods="POST">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
<default key="_format">xml</default>
<requirement key="_method">POST</requirement>
</route>

<route id="_webservice_definition" pattern="/{webservice}">
<route id="_webservice_definition" path="/{webservice}" methods="GET">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
<default key="_format">xml</default>
<requirement key="_method">GET</requirement>
</route>
</routes>
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ Annotations for Controllers
namespace Acme\DemoBundle\Controller;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("hello")
* @Soap\Param("name", phpType = "string")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ Controller
namespace Acme\DemoBundle\Controller;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("hello")
* @Soap\Param("names", phpType = "string[]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ Controller
namespace Acme\DemoBundle\Controller;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("returnAssocArray")
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
Expand Down Expand Up @@ -82,10 +85,13 @@ How to create my Associative Array?

use Acme\DemoBundle\Entity\User;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("getUsers")
* @Soap\Result(phpType = "Acme\DemoBundle\Soap\Type\User[]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ Controller
namespace Acme\DemoBundle\Controller;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("getUser")
* @Soap\Param("name", phpType = "string")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ Controller
namespace Acme\DemoBundle\Controller;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("hello")
* @Soap\Header("api_key", phpType = "string")
Expand Down Expand Up @@ -42,14 +45,16 @@ If you want use a header for all actions of your controller you can declare the
namespace Acme\DemoBundle\Controller;

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

/**
* @Soap\Header("api_key", phpType = "string")
*/
class DemoController extends ContainerAware
class DemoController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* @Soap\Method("hello")
* @Soap\Param("names", phpType = "string[]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace BeSimple\SoapBundle\ServiceDefinition\Loader;

use BeSimple\SoapBundle\ServiceDefinition as Definition;
use BeSimple\SoapBundle\ServiceDefinition\Annotation;
use BeSimple\SoapBundle\ServiceDefinition as Definition;
use BeSimple\SoapCommon\Definition\Type\ComplexType;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
use Doctrine\Common\Annotations\Reader;
Expand Down
2 changes: 1 addition & 1 deletion src/BeSimple/SoapBundle/Soap/SoapClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace BeSimple\SoapBundle\Soap;

use BeSimple\SoapClient\SoapClientBuilder as BaseSoapClientBuilder;
use BeSimple\SoapCommon\Classmap;
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
use BeSimple\SoapClient\SoapClientBuilder as BaseSoapClientBuilder;

class SoapClientBuilder extends BaseSoapClientBuilder
{
Expand Down
15 changes: 7 additions & 8 deletions src/BeSimple/SoapBundle/WebServiceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use BeSimple\SoapBundle\ServiceBinding\ServiceBinder;
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
use BeSimple\SoapWsdl\Dumper\Dumper;
use BeSimple\SoapServer\SoapServerBuilder;
use BeSimple\SoapWsdl\Dumper\Dumper;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\LoaderInterface;

Expand Down Expand Up @@ -44,7 +44,7 @@ public function getServiceDefinition()
if (null === $this->serviceDefinition) {
$cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
if ($cache->isFresh()) {
$this->serviceDefinition = include (string) $cache;
$this->serviceDefinition = include $cache->getPath();
} else {
if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) {
throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type']));
Expand All @@ -54,7 +54,7 @@ public function getServiceDefinition()
$this->serviceDefinition->setName($this->options['name']);
$this->serviceDefinition->setNamespace($this->options['namespace']);

$cache->write('<?php return unserialize('.var_export(serialize($this->serviceDefinition), true).');');
$cache->write('<?php return unserialize(' . var_export(serialize($this->serviceDefinition), true) . ');');
}
}

Expand All @@ -68,10 +68,10 @@ public function getWsdlFileContent($endpoint = null)

public function getWsdlFile($endpoint = null)
{
$file = sprintf ('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$cache = new ConfigCache($file, $this->options['debug']);

if(!$cache->isFresh()) {
if (!$cache->isFresh()) {
$definition = $this->getServiceDefinition();

if ($endpoint) {
Expand All @@ -82,7 +82,7 @@ public function getWsdlFile($endpoint = null)
$cache->write($dumper->dump());
}

return (string) $cache;
return $cache->getPath();
}

public function getServiceBinder()
Expand All @@ -105,8 +105,7 @@ public function getServerBuilder()
$this->serverBuilder = SoapServerBuilder::createWithDefaults()
->withWsdl($this->getWsdlFile())
->withClassmap($this->getServiceDefinition()->getTypeRepository()->getClassmap())
->withTypeConverters($this->converters)
;
->withTypeConverters($this->converters);

if (null !== $this->options['cache_type']) {
$this->serverBuilder->withWsdlCache($this->options['cache_type']);
Expand Down
Loading