Moved stylesheet option in WsdlDumper service and add the possibility to configure
This commit is contained in:
parent
33165ce8d2
commit
0e177bd067
|
@ -43,6 +43,8 @@ class BeSimpleSoapExtension extends Extension
|
|||
|
||||
$config = $processor->process($configuration->getConfigTree(), $configs);
|
||||
|
||||
$container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']);
|
||||
|
||||
foreach($config['services'] as $name => $serviceConfig) {
|
||||
$serviceConfig['name'] = $name;
|
||||
$this->createWebServiceContext($serviceConfig, $container);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
namespace BeSimple\SoapBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
/**
|
||||
|
@ -27,8 +28,16 @@ class Configuration
|
|||
public function getConfigTree()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('web_service');
|
||||
$rootNode = $treeBuilder->root('be_simple_soap');
|
||||
|
||||
$this->addServicesSection($rootNode);
|
||||
$this->addWsdlDumperSection($rootNode);
|
||||
|
||||
return $treeBuilder->buildTree();
|
||||
}
|
||||
|
||||
private function addServicesSection(ArrayNodeDefinition $rootNode)
|
||||
{
|
||||
$rootNode
|
||||
->children()
|
||||
->arrayNode('services')
|
||||
|
@ -55,7 +64,19 @@ class Configuration
|
|||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
||||
return $treeBuilder->buildTree();
|
||||
private function addWsdlDumperSection(ArrayNodeDefinition $rootNode)
|
||||
{
|
||||
$rootNode
|
||||
->children()
|
||||
->arrayNode('wsdl_dumper')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('stylesheet')->defaultNull()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
|
@ -44,6 +44,9 @@
|
|||
|
||||
<service id="besimple.soap.definition.dumper.wsdl.rpcliteral" class="%besimple.soap.definition.dumper.wsdl.rpcliteral.class%">
|
||||
<argument type="service" id="besimple.soap.definition.loader.annot_complextype" />
|
||||
<argument type="collection">
|
||||
<argument key="stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument>
|
||||
</argument>
|
||||
</service>
|
||||
|
||||
<service id="besimple.soap.converter.repository" class="%besimple.soap.converter.repository.class%" />
|
||||
|
|
|
@ -14,5 +14,5 @@ use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
|
|||
|
||||
interface DumperInterface
|
||||
{
|
||||
function dumpServiceDefinition(ServiceDefinition $definition, array $options = array());
|
||||
function dumpServiceDefinition(ServiceDefinition $definition, $endpoint);
|
||||
}
|
|
@ -25,27 +25,28 @@ use Zend\Soap\Wsdl;
|
|||
class WsdlDumper implements DumperInterface
|
||||
{
|
||||
private $loader;
|
||||
private $options;
|
||||
|
||||
private $wsdl;
|
||||
private $definition;
|
||||
|
||||
public function __construct(AnnotationComplexTypeLoader $loader)
|
||||
public function __construct(AnnotationComplexTypeLoader $loader, array $options)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->loader = $loader;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function dumpServiceDefinition(ServiceDefinition $definition, array $options = array())
|
||||
public function dumpServiceDefinition(ServiceDefinition $definition, $endpoint)
|
||||
{
|
||||
Assert::thatArgumentNotNull('definition', $definition);
|
||||
|
||||
$options = array_merge(array('endpoint' => '', 'stylesheet' => null), $options);
|
||||
|
||||
$this->definition = $definition;
|
||||
$this->wsdl = new Wsdl($definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition));
|
||||
$port = $this->wsdl->addPortType($this->getPortTypeName());
|
||||
$binding = $this->wsdl->addBinding($this->getBindingName(), $this->qualify($this->getPortTypeName()));
|
||||
|
||||
$this->wsdl->addSoapBinding($binding, 'rpc');
|
||||
$this->wsdl->addService($this->getServiceName(), $this->getPortName(), $this->qualify($this->getBindingName()), $options['endpoint']);
|
||||
$this->wsdl->addService($this->getServiceName(), $this->getPortName(), $this->qualify($this->getBindingName()), $endpoint);
|
||||
|
||||
foreach ($definition->getMethods() as $method) {
|
||||
$requestParts = array();
|
||||
|
@ -87,8 +88,8 @@ class WsdlDumper implements DumperInterface
|
|||
$dom = $this->wsdl->toDomDocument();
|
||||
$dom->formatOutput = true;
|
||||
|
||||
if (null !== $options['stylesheet']) {
|
||||
$stylesheet = $dom->createProcessingInstruction('xml-stylesheet', sprintf('type="text/xsl" href="%s"', $options['stylesheet']));
|
||||
if ($this->options['stylesheet']) {
|
||||
$stylesheet = $dom->createProcessingInstruction('xml-stylesheet', sprintf('type="text/xsl" href="%s"', $this->options['stylesheet']));
|
||||
|
||||
$dom->insertBefore($stylesheet, $dom->documentElement);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class WebServiceContext
|
|||
$cache = new ConfigCache($file, $this->options['debug']);
|
||||
|
||||
if(!$cache->isFresh()) {
|
||||
$cache->write($this->wsdlFileDumper->dumpServiceDefinition($this->getServiceDefinition(), array('endpoint' => $endpoint)));
|
||||
$cache->write($this->wsdlFileDumper->dumpServiceDefinition($this->getServiceDefinition(), $endpoint));
|
||||
}
|
||||
|
||||
return (string) $cache;
|
||||
|
|
Loading…
Reference in New Issue