From b1b0fb87f1707d05620dd9dab013abfa7a37c137 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Tue, 22 Nov 2011 23:00:59 +0100 Subject: [PATCH] Fixed issue #15 and #18 --- WebServiceContext.php | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/WebServiceContext.php b/WebServiceContext.php index 49d447a..556db5d 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -29,6 +29,8 @@ use Symfony\Component\Config\Loader\LoaderInterface; */ class WebServiceContext { + private $classmap; + private $typeRepository; private $converterRepository; @@ -55,15 +57,20 @@ class WebServiceContext public function getServiceDefinition() { if (null === $this->serviceDefinition) { - 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'])); + $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'])) { + throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type'])); + } + + $this->serviceDefinition = $this->loader->load($this->options['resource'], $this->options['resource_type']); + $this->serviceDefinition->setName($this->options['name']); + $this->serviceDefinition->setNamespace($this->options['namespace']); + + $this->typeRepository->fixTypeInformation($this->serviceDefinition); } - - $this->serviceDefinition = $this->loader->load($this->options['resource'], $this->options['resource_type']); - $this->serviceDefinition->setName($this->options['name']); - $this->serviceDefinition->setNamespace($this->options['namespace']); - - $this->typeRepository->fixTypeInformation($this->serviceDefinition); } return $this->serviceDefinition; @@ -76,14 +83,19 @@ class WebServiceContext public function getWsdlFile($endpoint = null) { - $file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint)); - $cache = new ConfigCache($file, $this->options['debug']); + $file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint)); + $cacheWsdl = new ConfigCache($file, $this->options['debug']); - if(!$cache->isFresh()) { - $cache->write($this->wsdlFileDumper->dumpServiceDefinition($this->getServiceDefinition(), $endpoint)); + if(!$cacheWsdl->isFresh()) { + $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('serverBuilder; } -} \ No newline at end of file +}