Added the possibility to add headers for a controller

Example:
    <?php

    namespace Acme\DemoBundle\Controller;

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

    /**
     * @Soap\Header("api_client_id", phpType = "int")
     * @Soap\Header("api_key", phpType = "string")
     */
    class DefaultController extends ContainerAware
    {
        // ...
    }
This commit is contained in:
Francis Besset 2011-09-20 22:34:16 +02:00
parent 33d1e4031c
commit dbeb00eae2
1 changed files with 16 additions and 2 deletions

View File

@ -58,15 +58,29 @@ class AnnotationClassLoader implements LoaderInterface
$class = new \ReflectionClass($class); $class = new \ReflectionClass($class);
$definition = new Definition\ServiceDefinition(); $definition = new Definition\ServiceDefinition();
$serviceMethodHeaders = array();
foreach ($this->reader->getClassAnnotations($class) as $annotation) {
if ($annotation instanceof Annotation\Header) {
$serviceMethodHeaders[$annotation->getValue()] = $annotation;
}
}
foreach ($class->getMethods() as $method) { foreach ($class->getMethods() as $method) {
$serviceArguments = $serviceArguments =
$serviceHeaders = array(); $serviceHeaders = array();
$serviceMethod = $serviceMethod =
$serviceReturn = null; $serviceReturn = null;
foreach ($this->reader->getMethodAnnotations($method) as $i => $annotation) { foreach ($serviceMethodHeaders as $annotation) {
$serviceHeaders[$annotation->getValue()] = new Definition\Header(
$annotation->getValue(),
$this->getArgumentType($method, $annotation)
);
}
foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
if ($annotation instanceof Annotation\Header) { if ($annotation instanceof Annotation\Header) {
$serviceHeaders[] = new Definition\Header( $serviceHeaders[$annotation->getValue()] = new Definition\Header(
$annotation->getValue(), $annotation->getValue(),
$this->getArgumentType($method, $annotation) $this->getArgumentType($method, $annotation)
); );