Fixed issue #15 and #18

This commit is contained in:
Francis Besset 2011-11-22 23:00:59 +01:00
parent 64e1759f45
commit b1b0fb87f1
1 changed files with 26 additions and 14 deletions

View File

@ -29,6 +29,8 @@ use Symfony\Component\Config\Loader\LoaderInterface;
*/ */
class WebServiceContext class WebServiceContext
{ {
private $classmap;
private $typeRepository; private $typeRepository;
private $converterRepository; private $converterRepository;
@ -55,6 +57,10 @@ class WebServiceContext
public function getServiceDefinition() public function getServiceDefinition()
{ {
if (null === $this->serviceDefinition) { if (null === $this->serviceDefinition) {
$cacheDefinition = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
if ($cacheDefinition->isFresh()) {
$this->serviceDefinition = include (string) $cacheDefinition;
} else {
if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) { 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'])); throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type']));
} }
@ -65,6 +71,7 @@ class WebServiceContext
$this->typeRepository->fixTypeInformation($this->serviceDefinition); $this->typeRepository->fixTypeInformation($this->serviceDefinition);
} }
}
return $this->serviceDefinition; return $this->serviceDefinition;
} }
@ -77,13 +84,18 @@ class WebServiceContext
public function getWsdlFile($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']); $cacheWsdl = new ConfigCache($file, $this->options['debug']);
if(!$cache->isFresh()) { if(!$cacheWsdl->isFresh()) {
$cache->write($this->wsdlFileDumper->dumpServiceDefinition($this->getServiceDefinition(), $endpoint)); $serviceDefinition = $this->getServiceDefinition();
$cacheWsdl->write($this->wsdlFileDumper->dumpServiceDefinition($serviceDefinition, $endpoint));
$cacheDefinition = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
$cacheDefinition->write('<?php return unserialize('.var_export(serialize($serviceDefinition), true).');');
} }
return (string) $cache; return (string) $cacheWsdl;
} }
public function getServiceBinder() public function getServiceBinder()