replaced old LoaderInterface with Symfony Config Component's LoaderInterface; added annotation based loader implementations;

This commit is contained in:
Christian Kerl
2011-04-08 00:41:16 +02:00
parent 70da526fd4
commit 8895a69d04
7 changed files with 321 additions and 61 deletions

View File

@ -10,6 +10,8 @@
namespace Bundle\WebServiceBundle\ServiceDefinition\Loader;
use Symfony\Component\Config\Loader\FileLoader;
use Bundle\WebServiceBundle\ServiceDefinition\ServiceDefinition;
use Bundle\WebServiceBundle\ServiceDefinition\Header;
use Bundle\WebServiceBundle\ServiceDefinition\Method;
@ -18,14 +20,20 @@ use Bundle\WebServiceBundle\ServiceDefinition\Type;
class XmlFileLoader extends FileLoader
{
public function loadServiceDefinition(ServiceDefinition $definition)
public function supports($resource, $type = null)
{
$xml = $this->parseFile($this->file);
return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION);
}
public function load($file, $type = null)
{
$path = $this->locator->locate($file);
$xml = $this->parseFile($path);
if($definition->getName() != $xml['name'])
{
throw new \InvalidArgumentException();
}
$definition = new ServiceDefinition();
$definition->setName((string) $xml['name']);
$definition->setNamespace((string) $xml['namespace']);
foreach($xml->header as $header)
{
@ -36,6 +44,8 @@ class XmlFileLoader extends FileLoader
{
$definition->getMethods()->add($this->parseMethod($method));
}
return $definition;
}
/**